Please find below another breakout intraday trading strategy built upon the breakout code Nicolas and Cosmic1 have already shared in the Library.
This one is for DAX 15 minutes, please change your time-zone accordingly to the obtained results (GMT+2 = Rome/Paris time-zone).
Tests were made with 1 point spread and results are quite good over the last years. Please share your thoughts and maybe improvements in the comments below. Thanks.
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
// MAIN CODE : BREAKOUT STRATEGY BY NICOLAS, COSMIC1 // INSPIRED BY BRAKOUT DAX 15MIN - COSMIC1 AND PROREALCODE SHARING COMMUNITY //------------------------------------------------------------------------- // IG MARKET GERMANY 30 CASH (EUR 1 MINI) - SPREAD 1 - 15 MIN // WE DO NOT STORE DATA UNTIL THE SYSTEM STARTS. // IF IT IS THE FIRST DAY THAT THE SYSTEM IS LAUNCHED AND IF IT IS AFTERNOON, // IT WILL WAIT UNTIL THE NEXT DAY FOR DEFINING SELL AND BUY ORDERS. //ALL TIMES ARE +0200 UTC/GMT DEFPARAM PRELOADBARS = 0 // POSITION IS CLOSED AT 21H00 PM DEFPARAM FLATAFTER = 210000 // NO NEW POSITION WILL BE INITIATED AFTER THE 16:00PM CANDLESTICK. ANY EXISTING ORDERS CANCELLED AT 17:15PM LIMITHOUR = 181400 // MARKET SCAN BEGIN WITH THE 15 MINUTE CANDLESTICK THAT CLOSED AT 9:15AM STARTHOUR = 091500 IF DAYOFWEEK =1 THEN TRADINGDAY = 0 ELSE TRADINGDAY = 1 ENDIF // VARIABLES THAT WOULD BE ADAPTED TO YOUR PREFERENCES IF TIME = 080000 THEN //POSITIONSIZE = MAX(1,1+ROUND((STRATEGYPROFIT-1000)/1000)) //GAIN RE-INVEST TRADE VOLUME POSITIONSIZE = 1 //CONSTANT TRADE VOLUME OVER THE TIME ENDIF MAXAMPLITUDE = 120 MINAMPLITUDE = 60 ORDERDISTANCE = 7 POURCENTAGEMIN = 20 // VARIABLE INITILIZATION ONCE AT SYSTEM START ONCE STARTTRADINGDAY = -1 // VARIABLES THAT CAN CHANGE IN INTRADAY ARE INITILIAZED // AT FIRST BAR ON EACH NEW DAY IF (TIME <= STARTHOUR AND STARTTRADINGDAY <> 0) OR INTRADAYBARINDEX = 0 THEN BUYTRESHOLD = 0 SELLTRESHOLD = 0 BUYPOSITION = 0 SELLPOSITION = 0 STARTTRADINGDAY = 0 ELSIF TIME >= STARTHOUR AND STARTTRADINGDAY = 0 AND TRADINGDAY = 1 THEN // WE STORE THE FIRST TRADING DAY BAR INDEX DAYSTARTINDEX = INTRADAYBARINDEX STARTTRADINGDAY = 1 ELSIF STARTTRADINGDAY = 1 AND TIME <= LIMITHOUR THEN // FOR EACH TRADING DAY, WE DEFINE EACH 15 MINUTES // THE HIGHER AND LOWER PRICE VALUE OF THE INSTRUMENT SINCE STARTHOUR // UNTIL THE BUY AND SELL TRESHOLDS ARE NOT DEFINED IF BUYTRESHOLD = 0 OR SELLTRESHOLD = 0 THEN HIGHLEVEL = HIGHEST[INTRADAYBARINDEX - DAYSTARTINDEX + 1](HIGH) LOWLEVEL = LOWEST [INTRADAYBARINDEX - DAYSTARTINDEX + 1](LOW) // SPREAD CALCULATION BETWEEN THE HIGHER AND THE // LOWER VALUE OF THE INSTRUMENT SINCE STARTHOUR DAYSPREAD = HIGHLEVEL - LOWLEVEL // MINIMAL SPREAD CALCULATION ALLOWED TO CONSIDER A SIGNIFICANT PRICE BREAKOUT // OF THE HIGHER AND LOWER VALUE MINSPREAD = DAYSPREAD * POURCENTAGEMIN / 100 // BUY AND SELL TRESHOLDS FOR THE ACTUAL IF CONDITIONS ARE MET IF DAYSPREAD <= MAXAMPLITUDE THEN IF SELLTRESHOLD = 0 AND (CLOSE - LOWLEVEL) >= MINSPREAD THEN SELLTRESHOLD = LOWLEVEL + ORDERDISTANCE ENDIF IF BUYTRESHOLD = 0 AND (HIGHLEVEL - CLOSE) >= MINSPREAD THEN BUYTRESHOLD = HIGHLEVEL - ORDERDISTANCE ENDIF ENDIF ENDIF // CREATION OF THE BUY AND SELL ORDERS FOR THE DAY // IF THE CONDITIONS ARE MET IF SELLTRESHOLD > 0 AND BUYTRESHOLD > 0 AND (BUYTRESHOLD - SELLTRESHOLD) >= MINAMPLITUDE THEN IF BUYPOSITION = 0 THEN IF LONGONMARKET THEN BUYPOSITION = 1 ELSE BUY POSITIONSIZE CONTRACT AT BUYTRESHOLD STOP ENDIF ENDIF IF SELLPOSITION = 0 THEN IF SHORTONMARKET THEN SELLPOSITION = 1 ELSE SELLSHORT POSITIONSIZE CONTRACT AT SELLTRESHOLD STOP ENDIF ENDIF ENDIF // CONDITIONS DEFINITIONS TO EXIT MARKET WHEN A BUY OR SELL ORDER IS ALREADY LAUNCHED IF LONGONMARKET AND (TIME> LIMITHOUR) THEN SELL AT SELLTRESHOLD STOP ELSIF SHORTONMARKET AND (TIME > LIMITHOUR) THEN EXITSHORT AT BUYTRESHOLD STOP ENDIF // LOGIC TRAILING STOP TGL =22 TGS=21 //RESET IF NOT ONMARKET THEN MAXPRICE = 0 MINPRICE = CLOSE PREZZOUSCITA = 0 ENDIF //SE LONG ALLORA: IF LONGONMARKET THEN MAXPRICE = MAX(MAXPRICE,CLOSE) //SAVING THE MFE OF THE CURRENT TRADE IF MAXPRICE-TRADEPRICE(1)>=TGL*POINTSIZE THEN //IF THE MFE IS HIGHER THAN THE TRAILINGSTOP THEN PREZZOUSCITA = MAXPRICE-TGL*POINTSIZE //SET THE EXIT PRICE AT THE MFE - TRAILING STOP PRICE LEVEL ENDIF ENDIF IF SHORTONMARKET THEN MINPRICE = MIN(MINPRICE,CLOSE) //SAVING THE MFE OF THE CURRENT TRADE IF TRADEPRICE(1)-MINPRICE>=TGS*POINTSIZE THEN //IF THE MFE IS HIGHER THAN THE TRAILINGSTOP THEN PREZZOUSCITA = MINPRICE+TGS*POINTSIZE //SET THE EXIT PRICE AT THE MFE + TRAILING STOP PRICE LEVEL ENDIF ENDIF //EXIT ON TRAILING STOP PRICE LEVELS IF ONMARKET AND PREZZOUSCITA>0 THEN EXITSHORT AT PREZZOUSCITA STOP SELL AT PREZZOUSCITA STOP ENDIF // MAXIMAL RISK DEFINITION OF LOSS PER POSITION // IN CASE OF BAD EVOLUTION OF THE INSTRUMENT PRICE SET STOP PLOSS MAXAMPLITUDE +(MAXAMPLITUDE) ENDIF //Regards Ale |
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
Hi ALE,
Thanks for posting this.
When i am changing times to suit my timezone (sydney Australia) am i changing FLATAFER, LimitHour, StartHour & IF TIME.
or just the IF time?
I am not understanding what to be changing . Sorry for this question.
Hello Jake
you’re welcome!
<pre id="tw-target-text" class="tw-data-text tw-ta tw-text-medium" dir="ltr" This should be the time for sidney
DEFPARAM FLATAFTER = 060000
LIMITHOUR = 031400
STARTHOUR = 181500
IF TIME = 170000 THEN
Hi Ale,
Thanks for your response. I am very new to this so just trying to get my head around the variables that i need to enter to get some results for this backtest?
I take it i am altering the buythresholds etc. I am not understanding your code to well.
Sorry for wasting your time with these questions.
Regards,
Hello Jake have you solved the problem?
Hi Ale,
No i have not been able to get any results at all. I must not have my variables correct or the time. I am not 100% sure what i am doing wrong.
Thanks
Hi
what time is it now for you?
Hi Ale, thanks for sharing. Do you think this version is curve fitted to the last two years? Did you avoid it some how? For 6 six years it did not do too much but only works in the last 2.. 2 Point spread is probably more realistic as you are closing a lot of trades when spread has changed. Cheers
I don’t understand, what do you think about?
Hi Cosmic,
I saw that you are able to do a backtest on DAX in 15Min timeframe till 6 years ago. In my PRT 10.3 i can only go back 2 years. Which Version are you using?
I think with only 156 trades it is easy to curve fit. It would be more promising to see that it has worked over many years or many more trades. Only my thoughts of course. How did you pick the variables?
The variables are the results of the optimization.
I’m using the platform complete version and I have only 100.000 bars to optimized the strategy.
I think that historical data are very important, If it doesn’t work in the last year may be a problem of performance. I think that it show the volatily of the dax.
grande Ale, ottimi contributi!
Grazie
Hi ALE,Thanks for your sharing. Nice code. However, Buy/sell at Price may lead to different result for Probacktest vs Live. Same case for your strategy?br,CKW
Hi CKW
thanks
I put it to work only yesterday on the demo account. I expect at least ten operations to see if the results are confirmed.
Excellent! Wait for your good news!
Hi Ale,
No i have not been able to get any results at all. I must not have my variables correct or the time. I am not 100% sure what i am doing wrong.
@JakeDB … by how much how you changed the times (+ or – ?) … just so we can make sure you have done it correct?
Also over what period (how many 15 min periods) are you running the Strategy?
Cheers
GraHal
Unfortunately I´ve got no results too….Do i have to change the timesettings? Im in Germany…best Regards..
Hi Senator-fred
Time setting is as follow:
//ALL TIMES ARE +0200 UTC/GMT
Thank´s, problem is solved…
Hello Ale, is my first comment in this forum. Thanks for your code. I wanted to ask if you are testing this EA on a real account. Thank you Luca
Hello Luca,no this strategy is overfitted.
Hello ALE
is that mean you are not going to use it live?
I don’t understand what is “overfitted”.
Hello Traderfed,
because it run many operations over the past three years, instead of having an average of operations performed stable over time..
Hello ALE
I’ve been running your strategy in demo for the last two weeks, but it hasn’t entry once, also i have noticed from December to March has only 1 position opened. Are you still running this system on demo or real?
Thanks
Ciao Ale, porta pazienza ma facendo copia incolla del codice non mi restituisce alcun valore. Devo modificare qualcosa eseguendolo dall’Italia? Grazie.
Ciao Ragazzi, ho qualche difficoltà applicare automaticamente una mia strategia con il renko che da dei buoni risultati. Cortesemente qualcuno mi potrebbe aiutare…..in anticipo grazie mille
Ciao GURU78,
Puoi aprire un TOPIC sul forum ProOrder Italiano, cosi ci spieghi che difficoltà incontri, e riceverai tutto l’aiuto possibile.
Ciao Ale grazie per il tuo apporto ma a me non restituisce nessuna operazione sul dax a 15 min e non dovrei avere nessun problema di fuso orario. C’è qualche settaggio che mi sfugge?
Grazie mille
fabio
Ciao Ale, il tuo codice è veramente interessante ma avrei bisogno di capire meglio questi parametri:
MAXAMPLITUDE = 120
MINAMPLITUDE = 60
ORDERDISTANCE = 7
POURCENTAGEMIN = 20
puoi aiutarmi?
Grazie
Hello
From july 2019 top july 2020 I have bad result :
Gain : +0.92%
win ratio 68%
profit factor = 1.04
This does not work anymore ?
Comment faites vous pour faire fonctionner cette stratégie ? ou est-elle obsolete ?
Hi Pat
This code was nothing more than an experiment
Hi Ale
Do you have same results as me ?
The strategy works very well in 2017 and now in 2-3 years later it fails.
How do you explain that ?
I don’t see a lot of numbers in the code that would explain over-optimization.
Built on the history means that it suits the history. Always develop ideas in In-Sample periods and test it in Out-Of-Sample periods should keep you away from overfitting … a bit.