Very simple strategy based on Kevin Davey book , I simply used his entry with ADX and a breakup/down of previous days value. See the code below :
DEFPARAM CumulateOrders = False
// Position Size
N = 2
lookbackbars = 10
ADXentry = ADX[15]<20
IF ADXentry THEN
BUY N CONTRACTS AT HIGHEST[lookbackbars](high) STOP
SELLSHORT N CONTRACTS AT LOWEST[lookbackbars](low) STOP
ENDIF
SET STOP pLOSS 90 %trailing 0.4
I’m sure there is a lot of ways to improve it. I’m currently to convert my stoploss into a trailing stoploss (as I have a limited account with IG, the trailing function isnt allowed). Also for accounts like mine, you will need to launch a LONG only and SHORT only version, as you can’t put two orders in opposite direction.
Line 12 is not allowed, since you are using two different forms to set a SL, you should use SET STOP pLOSS or SET STOP %TRAILING.
But almost everybody use external code snippets to replace the built-in SET STOP TRAILING.
You can simply add lines 17-56 (unchanged) from this link https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/, then change only the settings for TRAILINGSTART and TRAILINGSTEP.
i will check that. problem with breakout is having lot of losing trades
What is the WF result about that ?
I don’t have the book Entry and Exit Confessions of a Champion Trader but it’s a very interesting trader
LéoParticipant
Average
Hello
Cf the code including trailing stop as suggested by Roberto
//Simple ADX and Day High/Low breakout
//Very simple strategy based on Kevin Davey book
//BobFlynn
//Trailing stop function from Nicolas https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
DEFPARAM CumulateOrders = False
// Position Size
N = 2
lookbackbars = 10
ADXentry = ADX[15]<20
IF ADXentry THEN
BUY N CONTRACTS AT HIGHEST[lookbackbars](high) STOP
SELLSHORT N CONTRACTS AT LOWEST[lookbackbars](low) STOP
ENDIF
//************************************************************************
//trailing stop function
trailingstart = 90 //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
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=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
//************************************************************************
//GRAPH newSL as "trailing"