This automated trading strategy is about the breakout of Bill Williams fractals levels. It works well with EUR/USD pair on 1 hour time frame.
The following variables can be optimized:
Period of fractal level: CP= 110 to 114
Trailing Stop long: TGL = 5 to 15
Trailing Stop Short: TGS= 5 to 15
Stop loss by Donchian channel: DC = 15 to 30
Take profit : TP= 15 to 80
The concept of the strategy it’s universal, and It could work for equity/indices/currencies, with all time frame above 15 m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
//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 // 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 |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Again a nice code from you ALE.. *thumbs up*
Cheers Kasper
Happy to hear from your experience!Thanks Kasper
DAVVERO UN OTTIMO CODICE!
COMPLIMENTI
Grazie, provate ad usarlo anche su altri strumenti ottimizzando i parametri
I took just a quick look. I think it will take some time to fully understand the traling stop loss, but as always I really like to have defined a fixed stop loss. I don’t know why the plain set stop loss don’t work for eurusd so I came up with this.
It is just a suggestion so I’d like to hear your thoughts on it.
//EURUSD(-) – IG MARKET
// TIME FRAME 1H
// PROBACKTEST TICK by TICK – 200.000 bars
// SPREAD 0.6 PIP
// ALE
DEFPARAM CumulateOrders = false
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
The trailing stop start if close > tgl or close < tgs and move candles after candles.The second stop loss is donchian channel level.During my prockbatest I’ve seen that a stop loss above 40 pip works well also. I’m happy to see that your reinvestment code have a good equity in this strategy.I’ve started demo last week, results are only in probacktest, but the code is easy and i’ve already tested trailing stop in real, with other strategies and it work well.I like this strategy because:Low risk, low drawdown since 1998, in the walk farward results are well balanced, the donchian level stop loss it’s a correct interpretation of stop loss after a breakout, and the breakout level are confirmed by long candles in many cases, obviously we cannot discuss Bill William fractal level
I’m worried to know if this code works in real time well. We have to wait
Kasper your peace of code for reinvestment it’s excellence!
piece 😛
Bonjour j’ai testé votre code, vraiment impressionnant. J’ai envie de le tester en reel. Ma question est comment inclure ou juste savoir le coût du stoploss ? Car j’ai un compte CFD risque limité. Merci de votre réponse. Et merci pour ce code.
Thanks Ale,
Did you try do do a Walk forward with it ?
Zilliq
you can see walk f. picture above, it’s result with the original parameters
Yes zilliq
maybe it is a good idea to open a thread ….
And the results are ?
Thanks Ale
Zilliq I don’t know if I’ve attached picture
I have done walk forward myself with 200k bars, real ticks with 10 OOS periods and the results were nice, even with a larger spread than Ale mentioned. I kept the screenshots somewhere, maybe Ale could open a thread to discuss about it, good idea Paris! I think this one could be adapted to other Forex pairs also.
@ Parisyes good Idea!
Thanks Ale
Please use the new forum thread about this strategy to post picture: https://www.prorealcode.com/topic/fractal-breakout-intraday-strategy-eurusd-1h/
Hello Have you tested this code in real?
Fractal breakout intraday Stratégie EUR / USD 1H
Sorry guys but i have not the same results at all .
Does anybody have the same equity curve ?
Eur/usd 1 h – spread 0.6
In fact i have the dame , just my back test is a little shorter i only have 85 000 candles . Maybe i have an idéal to improve your back test , why ont to add a lot each 1000€ won . What do y ou think . I can give you a little snippet that do that .
In fact i have the same , just my back test is a little shorter i only have 85 000 candles . Maybe i have an idéal to improve your back test , why not to add a contract each 1000€ won . What do y ou think . I can give you a little snippet that do that
yes of course.. Have you seen Kasper’s code above?
OK mine is more simpler but does pretty thé same
I’ve open a new topic here: https://www.prorealcode.com/topic/fractal-breakout-intraday-strategy-eurusd-1h/
Thank you Ale, great code
snippet for modulation of contract
n = 1+(ROUND((strategyprofit)/7500))
every 7500 € it adds a contract …. of course you cuold modify it
Thanks Paris
Bella lì Ale!! Sei il n*1
magari!
Bonita estrategia. Gracias ALE
… thanks I hope could help our community!
It help me a lot. Excellent id “Merci”
🙂 Wim Thank you!
Hi, Im new to this forum and automated trading, so please excuse the nooby question:
If you have a trailing stop active why is the losses so high? $443 average loss??
Hello
because this trailing stop start next candles if condition is verified.
For more informations please use relative topic, don’t hesitate to ask more informations.
I have added the last version in the forum
https://www.prorealcode.com/topic/fractal-breakout-intraday-strategy-eurusd-1h/
Hello Ale,
What do you think of ? :
cp = 115
tgl = 1
tgs = 25
have a good day
Nico
why do you want to works the trading system with a trailing stop long of 1 point and the trailing stop short of 25 points?
oh yes I forgot : dc = 18 🙂
Ciao ALE. Recentemente sono passato a ProRealTime da VisualTrader e sto cercando di imparare la programmazione….. Sto studiando il tu Trading System con le modifiche di Elsborgtrading. Chiedevo per favore se potevi spiegrami perchè ci sono giorni interi in cui il sistema non entra in posizione e cosa significano queste due righe di codice “Capital = 10000” e “MAXpositionsize=5000
MINpositionsize=1”. Grazie
@Ale
Hi Ale,
Thanks for this rocking algo 😉 there is though a counter performance in 2018 and it seems it is after HIL and LOL crossed as normaly HIL is strictly > LOL; I whish I could insert an image but it is not possible on comments section;
very best,
Chris
Sorry here is my question: >> how can we explain this and correct it?
Hi ALE, would you be able to provide the values for the below part of the code (time >=100000 and time < 230000) , my time zone is Australia Perth. thanks
Bonjour,
J’ai testé cette stratégie sur EurUSD en 1 heures sur 10000 unités et le résultat est catastrophique
Aurais-je loupé quelque chose ?
Merci
Vue du rapport du Backtest https://ibb.co/8BMrBz6