Buy Straddle With BB Squeeze
Author: kamp95
Creation Date: 11/27/2019 9:35 PM
profile picture

kamp95

#1
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!!
profile picture

Cone

#2
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.
profile picture

superticker

#3
Slightly off topic, but I would checkout the interesting YouTube video on the WL Squeeze indicator page http://www2.wealth-lab.com/WL5Wiki/Squeeze.ashx?HL=squeeze. Now that video link there talks about doing the squeeze with long and short trades, not options. But you can certainly adapt the code to options.

Also, the ActiveTrader 2009-02 Double-band squeeze system strategy https://www.wealth-lab.com/Strategies/Forum/ActiveTrader-2009-02-The-double-band-squeeze-system-234 gives a Wealth-Lab strategy employing the WL Squeeze indicator. Again, it's employing long and short trades, but you can adapt it for options. Employing the WL Squeeze indicator may save some coding.
profile picture

kamp95

#4
@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.
profile picture

kamp95

#5
@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?
profile picture

Eugene

#6
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.
profile picture

kamp95

#7
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.
profile picture

Eugene

#8
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# ?
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).