Simple “Dax Breakout” trading strategy code

Simple “Dax Breakout” trading strategy code

Hello everyone,
Here is a small breakout strategy.
Here, I tested with the following settings:

– Range (channel) defined between 09H at 9H30

– On the DAX, 15 minute timeframe

– We play the breakout of high / low of the range

– Stop Loss: the other side of the range

– Take Profit: equal to the stop loss

As you can see, the code is simple.

The backtest is positive, even if it is not optimal.

Indeed, the max drawdown of € 6,548 (for an initial bet of € 10,000), for a capital gain of 51.80% per year. is too high.

We can decrease the contract size by 2 (max drawdown of € 3,274 for a capital gain of 25.90% per year), but the capital growth curve is still quite irregular.

However, this strategy seems logical and reliable, so I think there is much way to improve it.

It also works on CAC40 (or may some other indices).

But paradoxically it doesn’t work well on forex (I wanted to write it for forex, in order to use it automatically).

 

Share this

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?

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

  1. Eric • 04/08/2016 #

    Hi
    Have you tried to double the size if the first trade is a loss?
    I mean if the first breakout up is false then double the size on the next breakout down
    i would try it myself but i cant code it

  2. Doctrading • 04/08/2016 #

    Hello Eric,
    Of course it is possible. But for my backtests I don’t use martingale.
    Martingale is an easy solution to make you believe that your strategy works all the time… But the only time you loose, you loose much or all your money !
    Backtests without martingale are true results.
    Best Regards.

    • Nicolas • 04/08/2016 #

      Hello Doc, do you have tested the strategy with transactions costs also? Thanks.

  3. Doctrading • 04/08/2016 #

    Hi Nicolas,
    You are right, as it is in 15min timeframe, transaction costs are important.
    I will make the test later 😉

  4. Doctrading • 04/08/2016 #

    The same code with 1 point spread gives the following : 
    http://www.doctrading.fr/wp-content/uploads/2016/04/Breakout-DAX-spread-1.png
     
     
    A little ugly at beginning…
    I made no optimization for this code.Later, I will try to create a good breakout code (like “London Open Breakout” for GBP/USD, GOLD, DAX, etc.)

    • johnymon • 04/08/2016 #

      // Definition of code parameters
      DEFPARAM CumulateOrders = False // Cumulating positions deactivated

      j1=(DHigh(1) - DLow(1)) * .236
      j2=(DHigh(1) - DLow(1)) * .50
      // Conditions to enter long positions
      indicator1 = close //realtime price
      c1 = (indicator1 CROSSES OVER DHigh(1))

      IF c1 THEN
      BUY 2 PERPOINT AT MARKET
      ENDIF

      // Conditions to enter short positions
      indicator3 = close
      c3 = (indicator3 CROSSES UNDER DLow(1))

      IF c3 THEN
      SELLSHORT 2 PERPOINT AT MARKET
      ENDIF

      // Stops and targets
      SET STOP pLOSS j2
      // Stops and targets
      SET TARGET pPROFIT j1

      Hi Doctrading,
      I started using proreal time via my IGMarkets website and trying to code a similar breakout strategy  system  .I am finding difficulty in running  the system between only dax trading hours(07:00 to 19:00 UK time).I take previous day high/low and if  today’s price breaks  yesterday’s high/low , I bought /sell with target as (23.6% of yesterday’s high -low difference) points. The stop loss for both is (50% of of yesterday’s high -low difference) points.I wrote the code as attached.Could you please review the code and include the  trading hours restriction.  
      Thank you in advançe for your valuable time.
      Johnny
       

  5. Brage • 04/08/2016 #

    Hi
    Thanks for sharing. I’m new to autotrading.
    I thought this was a 30min breakout strategy with one position per day.
    Testing this on PRT/IG works ok with index (swedish omxs30) but when testing on stocks I get several positions during 9.30 and 18.00. Mostly one bar positions. What do I do wrong? Do I need to change something when testing on stocks?
    Best regards
    Martin

    • Nicolas • 04/08/2016 #

      Hi Martin, are you testing on a daily timeframe?

  6. janverhoeff • 04/08/2016 #

    Hi, if i want to do this whit 2 contracts then i only have to chanche N=1 to N=2??
    greetings Jan

    • Nicolas • 04/08/2016 #

      Hi Jan, yes “n” is the contracts size, you are right.

  7. Jan • 04/08/2016 #

    Thanks for the quick answer.
    Is it allso an idea to add a trailing stop extra to the system. start at the take profit zone?
     

    • Nicolas • 04/08/2016 #

      It is Doctrading’s strategy, maybe he could answer better than me to this question 🙂 Sometimes trailing stop just kill profit more than let it run, it needs some test here!

  8. Jan • 04/08/2016 #

    This morning the system startet and worked good whit 1 contract. halfe an houre ago i deleted the system and added a new one whit n=2.
    After a few minutes it started too sell 2 contracts.  it wasn’t in the ranges of 09:00 houres 09:30.  ho is this possible?
     

  9. Doctrading • 04/08/2016 #

    Hello,
    Of course this strategy needs improvement.
    It’s only good after 2014 (don’t forget to backtest it with spread ! the screenshot doesn’t show spread).
    Trailing stop would also be a nice idea. But first I test on several years with take profit, in order to see if it’s viable.
    Personnage, I wouldn’t use this one in real trading, as it is profitable only since 2014.

  10. Hockeytrader • 04/08/2016 #

    Hi! Thanks for this code. Im willing to make some adjustments but before that i need the code to be translated to english. Somebody who can help?

  11. Doctrading • 04/08/2016 #

    Hello Hockeytrader,
    I don’t understand you, the code is already in English, isn’t it ?

    • Hockeytrader • 04/08/2016 #

      Hi! Thanks for answer. Haut, bas, achat & vente are the words i’m thinking about.

  12. Doctrading • 04/08/2016 #

    “Haut” = “high”
    “Bas” = “low”
    “Achat & Vente” = “Buy & Sell”
    Google Translate is your friend 😉

  13. raj • 04/08/2016 #

    Hi
    Thanks for sharing. I have tried to use this code for a strategy I want to test on forex. The idea is to create an overnight range from the previous 8 hours and trade the breakout of this range from 9am onwards. Below is the code just for the long side of the stagey with 15min bars, hence (32) as this is 8h. I want it to go flat at 13:00, have added a trailing stop and a pip target. This are not optimised in any way, just first ideas to test.
    Anyhow, it does not seem to work. For some reason it does not take trades on certain days and sometimes take multiple trades on after another. I think one of the problems is the range is constantly being updated from the previous 32 bars, whereas I want it set rigid after 9am (highest/lowest 1am-9am). I thought the part ‘IF time = 090000’ would set this but not 100% sure, I am very new to this.
    Thanks in advance!
    Defparam cumulateorders = false
    Defparam flatafter = 130000
    n = 1
    IF Time = 090000 THENtop = highest[32](high)long = 0ENDIF
    if Time >= 090000 AND Time <= 130000 THEN
    IF long = 0 THENbuy n share at top stopENDIF
    ENDIF
    If longonmarket THENlong = 1ENDIF
    SET STOP pTRAILING 15set target pprofit 30

  14. Glen Marquis • 04/08/2016 #

    Only exit at other side of the 9.00-9.30 range, Dax moves far more “usually” than that!Perhaps try this with a 50+ target & 20 point stop trail.

  15. Hockeytrader • 04/08/2016 #

    I’ve had this thought that if the first trade goes wrong and we end up with a loose. Is it possible to make the second trade double size?

  16. Doctrading • 04/08/2016 #

    Hello, it is still possible, but I don’t like martingale.

  17. cupcake • 04/08/2016 #

    Hi, I’m trying to get my own system together that is very similar to the OP’s.
    It’s in essence a range breakout, but my range is the opening 5m bar of the day.
    stops and targets are similar theory to the OP’s as well,  Stop Loss: the other side of the range, Take Profit: equal to the stop loss
    I just can’t for the life of me amend this code to work, or get my own code.
    Is there anyone that’s able to help me with this at all?
     
    Thank you in advance.
     

  18. Doctrading • 04/08/2016 #

    Hello,
    Do you just consider the first 5min bar at 9AM as the range ?
    Yes, it is quite easy to backtest, but results will not be good. Because it is a too small timeframe, because of slippage, because of spread.
    Regards,

  19. cupcake • 04/08/2016 #

    it’s the first 5m bar on the 8am GMT open.
    Manually I would go long 2 points above the high of that first bar, with a stop 2 points below the low, and visa versa for the short entry.
    I’m just struggling to code it at the moment.

  20. Doctrading • 04/08/2016 #

    I will try later.If it is profitable, I will share the code.
    Do you take 2 trades a day even if the first is winning ? Or only one ?Regards,

  21. cupcake • 04/08/2016 #

    if the first hits the target then that’s the only trade.
    If doesn’t hit target, then opens the reverse trade when stopped.
    No trades at all after 12pm if long or short hasn’t triggered

  22. Hockeytrader • 04/08/2016 #

    Been testing the code for four weeks now. One optimisation i’ve been thinking about is to open a position when a bar closes over/under day h/l. who knows how that code would look?

  23. Doctrading • 04/08/2016 #

    The code should look like this : 
    Defparam cumulateorders = false

    // Timeframe : H1
    // HORAIRES DU BREAKOUT : 05H à 09H

    IF TIME = 080000 THEN
    HAUT = highest[1](high)
    BAS = lowest[1](low)
    achatjour = 0
    ventejour = 0
    amplitude = haut-bas
    ENDIF

    Ctime = time >= 080000 AND time <= 120000

    IF Ctime THEN
    IF achatjour = 0 THEN
    buy at HAUT + 1 stop
    ELSIF ventejour = 0 THEN
    sellshort at BAS - 1 stop
    ENDIF
    ENDIF

    IF longonmarket THEN
    achatjour = 1
    ENDIF
    IF shortonmarket THEN
    ventejour = 1
    ENDIF

    set stop loss amplitude
    set target profit amplitude

    But there is some issues : 

    I did’t set yet that if the first order is winning, there will be no second order
    it is winning without spread… but loosing with 1 point spread

    Feel free to improve this code.regards,

  24. Doctrading • 04/08/2016 #

     
    Just don’t consider the // timeframe   and // 05H to 09H   breakout.It was from an ancient london open breakout code.

  25. Hockeytrader • 04/08/2016 #

    Thanks. Will try it out.

  26. cupcake • 04/08/2016 #

    so I’ve tried to amend the OP’s code to look at a smaller range for my breakout, but I can’t get it to take any trades at all
    Defparam cumulateorders = false
    Defparam flatafter = 180000

    n = 1

    IF Time = 090501 THEN
    phigh = highest[2](high)
    plow = lowest[2](low)
    amplitude = phigh - psell
    pbuy = 0
    psell = 0
    ENDIF

    if Time > 090501 AND Time <= 180000 THEN

    IF pbuy = 0 THEN
    buy n share at phigh stop
    ENDIF

    IF psell = 0 THEN
    sellshort n share at plow stop
    ENDIF

    ENDIF

    If longonmarket THEN
    pbuy = 1
    ENDIF

    IF shortonmarket THEN
    psell = 1
    ENDIF

    set stop ploss amplitude
    set target pprofit amplitude

     

  27. Hockeytrader • 04/08/2016 #

    Hey. Been comparing the strategys performance versus the DAX volatility index. i’ve not done all 100 000 bars yet but so far the strategy is profitable when the $VDAX is somewhere between 15 & 25. Gonna work on this tonight and see if a can give you some kind of report.

  28. Dave • 04/08/2016 #

    Hi, I’m new to coding and have been trying to modify the code a little to backtest an idea I have but am struggling!.my idea is to take the first 8.00 uk m15 candle and create a sell order 25 points above the high and a buy order 25 from the low incorporating a simple 25 sl and 50tp.Any help would be greatly appreciated.
    Regards
    Dave

    • Nicolas • 04/08/2016 #

      Better use the forums for coding assistance please. You’ll get more results there for sure.

  29. Dave • 04/08/2016 #

    Apologies – only just learning the site layout.
    Maybe you could delete the post?

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
SAM
8 years ago
Elsborgtrading By adding the inside bar breakout failure candle, which is the next bar after the inside bar...
DegoodBoby very nice indicator but pls how can we use the indicator without the text (inside bar/brea...
ShaunG Hi Elsborgtrading thanks for this indicator. I was initially looking for a "IDnr4" which I c...
Wing Yes, investigate as much as you want. For more insight, you can view the linet1, linet2 etc....
CKW Hi Wing, Thanks for your sharing. I am still trying to breakdown & understand your code...
Wing Hello CKW. No, the parameter, 7 in this case, is used when calling the RSI indicator to ide...
Nacho Buenos días Raul, tengo puesto este sistema desde hace unos días en una cuenta demo en la ve...
Dominik Hola Raul ... it looks wonderful :-) Why does it not work if I use less than 100,000 € capi...
Bobbi Hola y gracias por compartir! Descubrí que en 5 minutos teníamos algo muy bueno! Pero no ...
pascal3431 Salut Doc , Je ne vois pas ce qui fait office de stop dans ce code .. un retour dans le nua...
Doctrading Bonjour, Il s'agit juste d'une stratégie où on est toujours en position : soit à l'achat / ...
pascal3431 Bonjour, après quelques essais sur EUR/USD au M15 en rajoutant(car sinon on est en perte) u...
Doctrading Nice Job ! Here is my version of the code :  KBO = 0 Tenkansen = (highest[9](high)+lowe...
gefinance Thanks for this code. The only thing left missing is the time lapse, otherwise, lots of old...
danhei Hi I am tryong to figure out how trist strategy works. I am new to pro real time. Can some...
Plop61 Hello,Thank you for sharing this beautiful strategy.Is it possible to indicate the code for ...
NoName Thank you very much for this fascinating trading system. It is still proving to be extremely...
ALE
8 years ago
pollon Ciao Ale,  anche a me da questo errore  "QQE_QUDAX1HBUY"  "QQE_QUDAX1HSELL"  "UNIV_QUDAX...
reb Hi Ale do you trade these QU strategies?  Are the results same as backtests Thnaks in adv...
avatar
crazytrader Hi anyone that has run this lately?
larouedegann best with this hour IF TIME =081000 THEN plushaut=highest[2](high) plusbas = lowest[2](lo...
CanAny1Trade Hi! I'm trying to put together a similar indicator but struggling. I want to mark the NY Pit...
ALE Hi Pat This code was nothing more than an experiment
pat95162 Hi Ale Do you have same results as me ? The strategy works very well in 2017 and now in 2-...
Nicolas Built on the history means that it suits the history. Always develop ideas in In-Sample peri...
ALE
8 years ago
ALE no, only with TF 15m
enzo_52 Grazie tante, Thanks so much 
JanWd Hallo Ale, First of all, thank you for this strategy. Could you explain what the BLUSTER ...
Nicolas Line 10: Volume of current candlestick must be at least 1.5 higher than the previous one and...
bibifricotin Bonjour Nicolas je viens d'essayer ce screener mais j'obtiens des résultats curieux .Aujourd...
Nicolas Décalage si compte gratuit fin de journée ?
Cosmic1
9 years ago
Cosmic1 Lets discuss here: https://www.prorealcode.com/topic/cac-breakout-ported-to-other-markets/
rejo007 hello, anybody use thi strategy for a long time? thanks
abacus23 Hi, I have been trading this strategy and it seems to work quite well recently. Is there a...
Elsborgtrading No that is wrong :) 1st runs always- then only run 2nd if 1st is on market with positions(ar...
Elsborgtrading It can only be fully automated if IG change minimum SLto 7 at night on DAX multi timefra...
Elsborgtrading A small example. the strategy would have opened 3 position on Dec 4th 2016 and keept it for ...
Cosmic1
9 years ago
Cosmic1 @JadeDB What times are you putting in?
sincitytrader I tried this one out recently,  and wasn't profitable for me.
Cosmic1 Yes, not great lately. I stopped this live at the end of last year. Will wait to see when th...
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...
dakaodo Years not defined was probably b/c Phillip copied and pasted the code into PRT instead of im...
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...
eiffel Hi Smurfy, hope you are still there... I would like to help you to write and test the code.
Reiner
9 years ago
Nicolas You should join and read the forum thread about this strategy. There are plenty of different...
Reiner Hi djtaktik and welcome, I have answered your question in the related Pathfinder forum beca...
danver34 is this version the definitive one or from the original one have there been modifications to...
Reiner
9 years ago
Nicolas Overfit on past history obviously. But it doesn't mean that it would still underperformed in...
Francesco78 Thank you for the clarifications Nicolas, I am more aware of the meaning of the backtesting ...
CanAny1Trade Hi all, could a simple indicator be made to mark the traditional Pit based ORB? I'm tryi...

Top