Hi, I am new to Wealth-Lab and was wondering if I could get some help with a strategy I am trying to code.
I would like to buy a straddle (buy both a put and a call at the same strike price with the same expiration date) when I see that a Bollinger Band Squeeze has occured. In other words, buy a straddle when the BB width reaches a new low within the past 50 days.
I then want to exit the straddle when the value of my straddle has decreased by more than 5% or if this never happens, sell the straddle within the last 6 hours of trading up to its expiration date (I don't want it to expire since we will have to buy quite a lot of shares of the stock).
I have the following code below started, but am looking for some guidance on how to create the stop loss of 5% on my straddle position.
CODE:
Please log in to see this code.
Any help would be greatly appreciated!!
Size:
Color:
As my last act before Thanksgiving, here's a better start for you. Run this on a daily data.
Later we can add plotting. Also to get that 6-hour constraint, you'll have to use intraday data (probably 30-min bars best).. but you have to walk before you can run!
CODE:
Please log in to see this code.
Size:
Color:
Size:
Color:
@superticker, I tried loading in the squeeze command but WLP didnt recognize it. Any reason why? I think this is a community created command?
@Cone, Thank you so much! The code worked, and I see some good results. I will try to reduce the time frame and look at each individual trade to see if the code works as intended.
Size:
Color:
@Cone, I have a follow up question regarding exiting the positions. I cannot find very good documentation from the WLP quick reference on the position command, so I was hoping you could help.
We enter a position with the command BuyAtMarket.
If we want to exit that SPECIFIC position, how do i do so?
Size:
Color:
QUOTE:
@superticker, I tried loading in the squeeze command but WLP didnt recognize it. Any reason why? I think this is a community created command?
Right. If you install
Community Indicators and restart WLP it will get recognized.
QUOTE:
If we want to exit that SPECIFIC position, how do i do so?
Since your new question is a general usage and/or off topic please ask it in a new thread. To keep our forum well maintained and organized let's have this thread focused on the very specific subject which is "buying straddles with BB Squeeze'. tia.
Size:
Color:
I've modified the code slightly to allow for me to add in another position and not close it.
The code compiles and runs, but the "Performance" tab shows that I am losing quite a bit of money now when compared to the previous code where I simply closed all positions.
Do you know why this would be?
CODE:
Please log in to see this code.
Size:
Color:
CODE:
Please log in to see this code.
Your slight modification just exits the put on the very first day that isn't an option expiry date. Did you forget about curly braces?
CODE:
Please log in to see this code.
You might consider this FAQ as a starting point:
How do I start with C# ?
Size:
Color: