PierParticipant
Veteran
Enter a long position when price break the highest within 4 bars
i use as filter “trend continuation factor” when the green line is over and adx
It provides a trailing stop and %stop loss
I suggest to download the strategy with the link below, to get the complete code (strategy + indicator at the same time when importing it).
bars = 21
barsback = 4
TcfL, TcfS = CALL "Trend Continuation Factor"[15]
if high = highest[bars](close) then
bi = barindex
hh = highest[bars](close)
endif
//conditions long
l1 = close crosses over hh
l1 = l1 and barindex < bi + barsback
l1 = l1 and TcfL > TcfS
l1 = l1 and adx[10] > 16
//enter position
if not onmarket and l1 then
buy at market
//SET TARGET PPROFIT AverageTrueRange[14](close)*6.5
endif
trailingstart = tradeprice/315 //trailing will start @trailinstart points profit
trailingstep = 5 //trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
SET STOP %LOSS 0.7
Hi Pier, thanks a lot for sharing this strategy with the community. I appreciate a lot.
I made a test over 200k bars and the first part of the history (OOS period) shows that the strategy is overfit over the last part (the one you develop and optimize the strategy on = screenshot attached).
It doesn’t mean the strategy is bad, perhaps it could become more “robust” with new optimization made every X bars, the Walk Forward tool will help you find how and when to do it. Thank you again 🙂
Looks good!
I like that it not drop below zero / still gains over the non-optimised 100k bars in Nicolas equity curve … shows plenty of potential!
I’m setting it going in Demo right now! 🙂
Let us know please if you make any changes after using WF etc.
I will report back likewise.
Thank You
GraHal
PS Might you consider adding shorts also? I think the DAX is due a correction?
PierParticipant
Veteran
bars = 21
barsback = 4
TcfL, TcfS = CALL "Trend Continuation Factor"[9]
ac = CALL "accelerator adx"[5, 100]
if high = highest[bars](close) then
bi = barindex
hh = highest[bars](close)
endif
//conditions long
l1 = close crosses over hh
l1 = l1 and barindex < bi + barsback
l1 = l1 and TcfL > TcfS
l1 = l1 and adx[10] > 16
l1 = l1 and ac > 0.9
//enter position
if not onmarket and l1 then
buy at market
//SET TARGET PPROFIT AverageTrueRange[14](close)*6.5
endif
ADX accelerator
mShort = adx[adShortPeriod]
mLong = adx[adLongPeriod]
ad = max(0, (abs(mShort) / abs(mLong)) -1)
return ad as "acd"
Try to set It in this way: using ADX accelerator too and tcf[9] . It seems that it works better
Short position is not so good I don’t why