Breakout intraday trading strategy on DAX

Breakout intraday trading strategy on DAX
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.

 
// 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
Risk disclosure:

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 : How to import ITF files into ProRealTime platform?

New! PRC is also now on YouTube, subscribe to our channel for exclusive content and tutorials

  1. JakeDB • 93 days ago #

    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. 

  2. ALE • 93 days ago #

    Hello Jake
    you’re welcome!

     DEFPARAM FLATAFTER = 060000
    LIMITHOUR = 031400
    STARTHOUR = 181500
    IF TIME = 170000 THEN
     
    • JakeDB • 92 days ago #

      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, 

    • ALE • 90 days ago #
      Hello Jake 
      have you solved the problem?

    • JakeDB • 89 days ago #

      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

    • ALE • 89 days ago #

      Hi 

      what time is it now for you?

  3. Cosmic1 • 93 days ago #

    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

    • ALE • 93 days ago #

      I don’t understand, what do you think about?

  4. Cosmic1 • 93 days ago #

    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?

    • ALE • 93 days ago #

      The variables are the results of the optimization.

    • ALE • 93 days ago #

      I’m using the platform complete version and I have only 100.000 bars to optimized the strategy. 

  5. ALE • 93 days ago #

    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.

  6. criscolci • 93 days ago #

    grande Ale, ottimi contributi!

     

  7. CKW • 91 days ago #

    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

  8. ALE • 91 days ago #

    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.

  9. CKW • 91 days ago #

    Excellent! Wait for your good news!

  10. JakeDB • 89 days ago #

    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. 

     

  11. senator-fred • 83 days ago #

    Unfortunately I´ve got no results too….Do i have to change the timesettings? Im in Germany…
    best Regards.. 

    • ALE • 83 days ago #

      Hi Senator-fred

      Time  setting is as follow: 

      //ALL TIMES ARE +0200 UTC/GMT
  12. senator-fred • 81 days ago #

    Thank´s, problem is solved…

  13. Luca81 • 64 days ago #

    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

    • ALE • 64 days ago #

      Hello Luca,
      no this strategy is overfitted. 

  14. traderfred • 18 days ago #

    Hello ALE

    is that mean you are not going to use it live?

    I don’t understand what is “overfitted”.

  15. ALE • 18 days ago #

    Hello Traderfed,

    because it run many operations over the past three years, instead of having an average of operations performed stable over time..

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
Raul Vg the same robot with trailing stop and other type of accumulator (you can keep the previous a...
Raul Vg A mi me dan solo 100.000, puedo ver año y medio
Raul Vg Yes, I have also tried it. But I would like someone who had 200,000 bars to show us how he b...
Jake26 Thanks for sharing your work with this code, Doc. Impressive results in backtests with shor...
Doctrading Hello, Actually I'm not trading this strategy. I'm looking to make a good automated tradin...
Rohan Hello Doctrading,  I am also very interested in the Ichimoku (I am trading it but discretio...
Doctrading Nice Job ! Here is my version of the code :  KBO = 0 Tenkansen = (highest[9](high)+lowe...
triss1965@gmail.com The code dose not work   Syntax error: line 2, character 12One of the following chara...
triss1965@gmail.com why do I get error ond line whit DAX? Eihter cod works. Can you chare the file?
Elsborgtrading Hi Triss. the File is in the post for download. There is nothing wrong with the code. Your e...
ALE
2 months ago
ALE CiaoGuadagno.
alemaliz Ciao Ale scusa se ti disturbo ancora possiamo sentirci in privato per un chiarimento su ques...
ALE Ma certo nel mio profilo trovi le info
ALE
3 months ago
enzo_52 Hi Ale, so you have the same results with german 30 mini 1e cash TF 1h?  
ALE no, only with TF 15m
enzo_52 Grazie tante, Thanks so much 
Nicolas
4 months ago
century hi, can we have more explanations please ? about parameters and time unit ? thanks
Nicolas Line 10: Volume of current candlestick must be at least 1.5 higher than the previous one and...
Cosmic1
4 months ago
Cosmic1 Hi Yngve, Amplitude relates to the range of the price action for the given times stipulated...
GAMMA I try as per your advise and change the time to usa time still no luck, may be I am doing so...
Cosmic1 Post the code you are using, will try and figure it out. What broker?
Elsborgtrading Hi Nicolas, and thanks for updating the file. When I backtest the code now I get a complete...
Elsborgtrading Hi Nicolas. I made a mistake. a FTSE chart had sneaked under the DAX and when backtesting I ...
Nicolas "set stop loss" are individual for each order with IG.
Cosmic1
5 months ago
Cosmic1 Hi Vish, Yes it was a good Thursday and Friday where between DAX and DOW breakout +800 point...
JakeDB I cannot get my time conversions correct for Sydney Australia to get any data for this code....
Cosmic1 @JadeDB What times are you putting in?
Philip Raphael Hey! Thank so much for sharing this wonderful indicator! I have always tried to code a simil...
CKW Hi Philip, What do you mean "Years" are not defined ? candle? If to code yearly candle size...
zilliq The reasons why I think it's time consuming and we loose time to try to do backests and Auto...
filiprb Hello Zilliq, You don't need a system to produce a walk forward test. You can easily create...
Philip Raphael It is incredible! Thanks for sharing, Doctrading!
Doctrading Hello, As I said, I didn't use spread for the screenshot as I don't trade Gold and I don't ...
smurfy Hi, I had been losing on gold and after I manually go through the 5min chart using IG and w...
Reiner
7 months ago
Pathfinder DAX 4H
Pathfinder DAX 4H
183
Strategies
Bandido Emanuele, vai nel forum e troverai di tutto e di più ;-)
Reiner Hi Emanuele and welcome, You'll find the latest versions at the first post in the related f...
volpiemanuele Tanks, if I want to enter in a market only with 1 lot do you confirm that I cam modify only ...
Reiner
7 months ago
tradex Hello, what is the simple average period on equity curve ? Thank you in advance
Reiner tradex, open the settings dialog (click on wrench symbol) on the equity curve window and add...
Daniel da Costa Hi Nicolas! Is it possible too reference the MA in the equity curve so as too know whether t...
finplus Hi Wanjpt, I tried once only on AUD / USD in november 2016 during one day. No position has b...
finplus The backtest of the code works perfectly with 1 hour timeframe.
CN Anyone got a correct code for the setup?Used Minihax code with mixed results... Anyone that ...
GraHal I adjusted for GMT (minus 1 hour on all times) ... no trades. Might it be because the code ...
GraHal Ooops got that excited I sent that last one twice! ha (and can't delete it, sorry) I got it...
Eric n = 3  dont forget to allow 3 contract in proorder
Obiwano Dear Adolfo, Have you been trading this strategy now in real?  What is the outcome?  Which ...
ernesto Hey it doesn't work there are not any buy or sell.
verdi55 Result now : a loss of 1080 Euros in the past 8 months. Were there some parameters over-opti...
Doctrading Hello, Someone asked me something (his results seemed to be different) on my email, but it ...
Samsam13   what i wanted to say, is that if you enter now into this pattern of auto trading, yo...
Nicolas Yes you are right, maybe I need to add more disclaimer? I'm actually trading some automated ...
Doctrading Hello Samsam13, I hope you are well.  As you can see, some of us post various strategies. B...

Top