I stumbled over an article about a channel breakout system that varies the length of the channel depending on volatility.
Here is the article:
https://www.quantconnect.com/tutorials/dynamic-breakout-ii-strategy/
I thought it was an interesting idea and programmed it. It produces quite good backtest for EURUSD on daily bars.
There are not many trades but maybe this can be developed in a useful strategy. Varying the deviation of the bollinger bands would be definitely worth trying (i did not try that). I just took the rules from the articles and gave it a run – no optimization at all.
I almost forgot, I made 1 change. The article uses the standard deviation of the lookback as measure for volatility. I had this first and this worked but then i tried ATR instead as measure of volatility and results improved. The code to use standard deviation instead of ATR is there still as comment.
defparam cumulateorders=false
once lookback=20
once positionsize=1
atr=AverageTrueRange[lookback](close)
tradingtime=(currentdayofweek>=1 and currentdayofweek<=5)
If tradingtime then
todayvol=atr //STD[lookback](close)
ydayvol=atr[1] //STD[lookback](close[1])
deltavol=(todayvol-ydayvol)/todayvol
lookback=round(lookback*(1+deltavol))
lookback=MIN(60,lookback)
lookback=MAX(20,lookback)
MA=Average[lookback](close)
BoUp=BollingerUp[lookback](close)
BoDown=BollingerDown[lookback](close)
LC1=close[1]>BoUp
LC2=close>highest[lookback](high[1])
SC1=close[1]<BoDown
SC2=close<lowest[lookback](low[1])
if LC1 and LC2 then
buy positionsize contract at market
elsif SC1 and SC2 then
sellshort positionsize contract at market
endif
if longonmarket and (close < MA ) then
sell at market
elsif shortonmarket and (close > MA ) then
exitshort at market
endif
endif
Thank you Despair for sharing this code with us. Could be a nice addition to the library too, just for learning purpose and maybe helping others ideas come to us. Should work with other forex pairs with some WFO for validation?
Apparently, the good trade (big breakout) are greatly helping the equity curve to climb up! False signals came from ranging market and it can still long times like months/years 🙁
Definitely. This is nothing you want to trade as is. But I thought the idea is interesting and maybe somebody wants to proceed to work with it. I did not put much work/time in it.