ALEModerator
Master
Hello guys We can discuss about the strategy here, we can help together to develop the strategy . This is the strategy posted in the Library there : https://www.prorealcode.com/prorealtime-trading-strategies/fractal-breakout-intraday-strategy-eurusd-1h/ Below you can find 3 screenshot with explanation of the stop, and levels used in this strategy.
// EURUSD(-) - IG MARKET
// TIME FRAME 1H
// PROBACKTEST TICK by TICK - 200.000 bars
// SPREAD 0.6 PIP
// ALE
DEFPARAM CumulateOrders = false
///BILL WILLIAM FRACTAL INDICATOR
//CP=PERIOD
CP=113
if close[cp] >= highest[2*cp+1](close) then
LH = 1
else
LH=0
endif
if close[cp] <= lowest[2*cp+1](close) then
LL= -1
else
LL=0
endif
if LH=1 then
HIL = close[cp]
endif
if LL = -1 then
LOL=close[cp]
endif
//LONG and SHORT CONDITIONS
Positionsize=1
if (time >=100000 and time < 230000) then
C1 = (close CROSSES OVER HIL)
D1 = (close CROSSES UNDER LOL)
IF c1 and not shortonmarket THEN
BUY positionsize CONTRACT AT MARKET
ENDIF
IF D1 and not longonmarket THEN
SELLSHORT positionsize CONTRACT AT MARKET
ENDIF
ENDIF
//TRAILING STOP
TGL =5
TGS=5
if not onmarket then
MAXPRICE = 0
MINPRICE = close
PREZZOUSCITA = 0
ENDIF
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=TGL*pointsize then
PREZZOUSCITA = MAXPRICE-TGL*pointsize
ENDIF
ENDIF
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
PREZZOUSCITA = MINPRICE+TGS*pointsize
ENDIF
ENDIF
if onmarket and PREZZOUSCITA>0 then
EXITSHORT AT PREZZOUSCITA STOP
SELL AT PREZZOUSCITA STOP
ENDIF
// DONCHIAN STOP
DC=20
e= Highest[DC](high)
f=Lowest[DC](low)
if longonmarket then
laststop = f[1]
endif
if shortonmarket then
laststop = e[1]
endif
if onmarket then
sell at laststop stop
exitshort at laststop stop
endif
set target pprofit 30
This trading sistem can be used with other currency pairs. To find the values of variables suitable for other currency pairs, you must use WF, to avoid an overfitted values: if the WF will be done on bars 200,000 may be divided into two halves, the first test will be carried out with a large range value starting with the value in the attached picture below, the second test will have a range around the variables choices during the first test. IN THE LAST YEAR THE OPTIMIZATION OF TRAILING STOP SUGGEST THIS VALUE: TGL=9 TGS=10 … THIS MEAN ABOUT 10 PIP FOR BOTH
ALEModerator
Master
This the reinvestment version of Kasper, in his example him stressed the strategy with 5000 lots:
//EURUSD(-) - IG MARKET
// TIME FRAME 1H
// PROBACKTEST TICK by TICK - 200.000 bars
// SPREAD 0.6 PIP
// ALE - KASPER
DEFPARAM CumulateOrders = false
//KASPER CODE OF REINVESTMENT
Reinvest=1
if reinvest then
Capital = 10000
Risk = 1//0.1//in % pr position
StopLoss = 48
REM Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*(Risk/100))
MAXpositionsize=5000
MINpositionsize=1
Positionsize= MAX(MINpositionsize,MIN(MAXpositionsize,abs(round((maxrisk/StopLoss)))))//*Pointsize))))
else
Positionsize=1
StopLoss = 48
Endif
///BILL WILLIAM FRACTAL INDICATOR
//CP=PERIOD
CP=113
if close[cp] >= highest[2*cp+1](close) then
LH = 1
else
LH=0
endif
if close[cp] <= lowest[2*cp+1](close) then
LL= -1
else
LL=0
endif
if LH=1 then
HIL = close[cp]
endif
if LL = -1 then
LOL=close[cp]
endif
// RETURN, HIL COLOURED(0,200,0) AS "BREAKOUT LEVEL LONG",HIL COLOURED(200,0,0) AS "BREAKOUT LEVEL SHORT"
//LONG and SHORT CONDITIONS
//Positionsize=1
if (time >=100000 and time < 230000) then
C1 = (close CROSSES OVER HIL)
D1 = (close CROSSES UNDER LOL)
IF c1 and not shortonmarket THEN
BUY positionsize CONTRACT AT MARKET
ENDIF
IF D1 and not longonmarket THEN
SELLSHORT positionsize CONTRACT AT MARKET
ENDIF
ENDIF
//TRAILING STOP
TGL =5
TGS=5
if not onmarket then
MAXPRICE = 0
MINPRICE = close
PREZZOUSCITA = 0
ENDIF
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=TGL*pointsize then
PREZZOUSCITA = MAXPRICE-TGL*pointsize
ENDIF
ENDIF
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
PREZZOUSCITA = MINPRICE+TGS*pointsize
ENDIF
ENDIF
if onmarket and PREZZOUSCITA>0 then
EXITSHORT AT PREZZOUSCITA STOP
SELL AT PREZZOUSCITA STOP
ENDIF
// DONCHIAN STOP
DC=20
e= Highest[DC](high)
f=Lowest[DC](low)
if longonmarket then
laststop = f[1]
endif
if shortonmarket then
laststop = e[1]
endif
if onmarket then
sell at laststop stop
exitshort at laststop stop
endif
set target pprofit 30
set stop loss stoploss*pointsize
@kasper could you comment it?
Great idea Ale 🙂 how does the stoploss 48 do in the 200000 units and walk forward?
edit: I see you already did it :). Ill take a look later when on the pc
cheers Kasper
EricParticipant
Master
tick by tick backtest? trailingstop 5?
tick by tick backtest? trailingstop 5?
This is the
MFE trailing stop, exit levels are only update once per bar at each calculation.
Please find attached the pictures of my own WF test with the first version of the strategy (200.000 bars, ticks mode, 1 point spread) over 10 Out Of Sample iterations.
I think that to suit the strategy for over forex pairs, the best solution would be to enlarge the fractals period (‘cp’ variable) minimum and maximum for the optimisation. That would adapt the high/low fractals for each pair behaviour. Since WF optimisation take ages, I encourage anyone willing to help to test if this rough idea could be relevant and to continue explore other possibilities of improvements. Thanks.
@Nicolas,
Do you erase of my WF test and the picture ?
Hi Ale, that is just crazy numbers 🙂 I don’t have the premium version- but for 1 H data back to 1999, that is a valid test. I would like to help optimize but the data I have is only back to Jan. 2013
Please add this Graph code- to see how much you are risking at each trade.
graph (((tradeprice-(tradeprice-((tradeprice*stoploss)/100)))*positionsize*pointvalue*100)/(equity))*100 COLOURED(0,0,0) AS "MAXRISK"
@zilliq yes sorry, please repost it here.
ALEModerator
Master
Hi Kasper
I’ve attached pic with maxrisk curve and some value along the curve
Thanks Ale. if you use in the reinvestment code, it should very soon stabilize around 1% risk
No problem Nicolas
I do a WF on 100 000 bars and the WF ratio was 36 % and 3 of 5 periods were >50 %
I did a try by replacing TGL and TGS by a coefficient of averagetruerange, but the results was not good 🙁
ALEModerator
Master
@ Zilliq what do you mean?
ALEModerator
Master
@KASPER
This is results with 1 lot and risk 0.3
@ALE Zilliq tried to use a dynamic step instead of a fixed one with the help of ATR.
Did someone tried to optimize with another pair already?