Day-Trading the DAX with the Trend

Day-Trading the DAX with the Trend

Hi all !

Here is a very simple code, but very effective, in order to trade the DAX.

It’s a Day trading strategy, but it is designed for H4 timeframe.
It concerns the 3 candles : from 9AM to 21PM.

We go long at 09AM if :
close > 200 moving average
MACD > 0

We close positions at 21PM.

Stop loss and take profit : 1% and 3%

That’s all !

As you see, this very simple trend following strategy is positive (with spread : 1 point), on the last 10 years.
It is’nt before, but I think the DAX CFD trading hours were different.

It should be easy to improve this code, I’ve already made some improvements.
But I prefer giving you the basic and simple (but effective !) code.



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. Samsam13 • 04/30/2016 #

    TP at 3%, isn’t it a bit too much ? Someone knows how many trading days saw the DAX moving than more than 3 % ?

  2. Doctrading • 04/30/2016 #

    You reach TP very very few times.
    Buy it happens on some days.
    Most of the time, you close at evening, that’s all.Without TP ans SL, the strategy is still profitable.

  3. Samsam13 • 04/30/2016 #

    so you count more on the “flatafter” than on tp ?

  4. Doctrading • 04/30/2016 #

    Yes, that’s the way. 

  5. keshejo • 04/30/2016 #

    Hi, i’m from Perú
    The time is 09:00 to 21:00 GMT? 

  6. Doctrading • 04/30/2016 #

    It’s 9:00 on my broker (ProRealTime CFD), so I think it is GMT+1.

  7. Doctrading • 04/30/2016 #

    Hi all,
    Would you trade using this strategy, as it is really profitable since 2014 ?Thanks.

  8. Yngve • 04/30/2016 #

    So between 2009 and 2012 you take no profit, thats a long time to sit around and see it do nothing.

    • Nicolas • 04/30/2016 #

      Yes and that’s why a lot of strategies are never published, because people are impatient… This strategy are proof that automated trading work, so just sit and relax, and make profit while doing nothing. 😉

  9. Ad • 04/30/2016 #

    Hi, I am not sure if this is the right way to do this but I see here many professionals that maybe can help here to figure this up…
    I wrote a simple, similar code and its opposite one, i.e., entering in the counter position when exact the same condition occurs, TP3% and SL1%.
    To my overwhelming, when activating the both on the same time frame (Daily) at the same period (last month) I saw days where both came profit.
    Can you explain? Attached is added 
    // Conditions First code// Condition to enter long

    c3L = MACD[12,26,9](close)<0//close < open

    IF c3L and NOT ONMARKET and currenttime > 100000 THEN

    // Conditions to enter short

    c3S = MACD[12,26,9](close)>0//close > open

    IF c3S and NOT ONMARKET and currenttime > 100000 THEN

    //--- Conditions Second code----
    // Conditions to enter longc3L = MACD[12,26,9](close)>0//close > openIF c3L and NOT ONMARKET and currenttime > 100000 THENBuy 1000 Cash ROUNDEDDOWN AT MARKETENDIF// Conditions to enter shortc3S = MACD[12,26,9](close)<0//close < openIF c3S and NOT ONMARKET and currenttime > 100000 THENSELLSHORT 1000 Cash ROUNDEDDOWN AT MARKETENDIFSET TARGET %PROFIT 3SET STOP %LOSS 1

  10. Samsam13 • 04/30/2016 #

    We’re talking about trading, on derivatives, when you could potentially lose a lot. You shouldn’t be talking about “making profit while doing nothing” Nicolas, that sounds so awkward and untrue. I’m testing this strategy and i just had a drawdown of 8 losses, losing 2000 € (in test hopefully).

    • Nicolas • 04/30/2016 #

      8 losses in a row sounds possible in trading. Strategies in library are there because people were kind enough to share what they discovered while coding. FYI, there are a lot of codes that I don’t approve to be featured in. My answer to Yngve may be sound sarcastic, but that’s the way how I talk sorry for that, did I mention I put a smiley? Anyway, 2k€ is how much percent of your demo account?

    • Doctrading • 04/30/2016 #

      The backtest shows a maximum loosing streak of 8 consecutive trades. So it is possible.
      That’s trading, you could also have 8 winning trades.
      That’s also why I don’t like martingale.

  11. Samsam13 • 04/30/2016 #

    hopefully – thankfully

  12. Samsam13 • 04/30/2016 #

    then i’ll have a smiley too

  13. Samsam13 • 04/30/2016 #

    and thanks for all the advice

  14. Samsam13 • 04/30/2016 #

    what i wanted to say, is that if you enter now into this pattern of auto trading, you would have a drawdown of 9 consecutive losses, wich could kill your account, so even with a smiley, please do consider that people that would read you would take what you say very seriously (either clients, or regulators). Some are really seeking for a way to earn money doing nothing in a secure way, we have to be very careful in what we say and the way we say.

    • Nicolas • 04/30/2016 #

      Yes you are right, maybe I need to add more disclaimer? I’m actually trading some automated system that can kill my account and I assume myself the responsibility of my own trading decision. There are no “blackbox” system here, all codes are readable by everyone, they are free and no one are earning money by putting them on this website. I’m not selling ebook or magical potion to make everyone a millionaire, there are also no publicity on the site.
      My attention for the answer I made were to say that criticism is easy when you just click and download. Trading systems that do not make profit even in 2 consecutive years do not invalidate a strategy that work well over a decade. We could have this discussion in every code shared here, sometimes things go bad, sometimes trades go well.. that’s how it goes and no one can change this..

  15. Doctrading • 04/30/2016 #

    Hello Samsam13,
    I hope you are well.  As you can see, some of us post various strategies. But you must understand that :

    these are not definitive and commercial strategies. These a good strategies that we publish for free, as “open codes”. So everyone can use and improve those strategies (the goal is to improve them), but it doesn’t mean that these strategies are always used by ourselves.
    myself, I don’t use all the strategies that I did post, of course ! I use only 3 strategies of my own. And it is less than 10% of my capital. The > 90% of my capital is secured investment.
    Even the better traders who get 100% annual return in trading tournaments have drawdowns… usually 50% drawdown.
    9 consecutive losses doesn’t have to make afraid, depending of the strategy. The rule n°1 of trading is : PROTECT your capital ! So I don’t bet more than 1% risk per trade (when I was a beginner, I did bet 5 to 10% sometimes… it did annihilate my account twice, and nearly a third time). 9 consecutive losses would be 9%. But if the reward ratio is 3:1, only 5 wins would make +15%. See for example the “Breakout ProOrder CAC40” : the winning ratio is low, but the strategy wins on the long term, because average wins are greater than average losses.
    This is what Nicolas wisely said : some losses do not invalidate a good strategy. Maybe we will have soon a “disclaimer” word.

    I hope this helps, and I wish you good trades. You can ask for help whenever.Best regards,

  16. Wilko • 04/30/2016 #

    Dear Nicolas,
    Thanks for posting this! It is always interesting to see what people have found to work. One question: In the picture for the article, the results page shows both long and short positions, while the code is strictly long-only. Is the picture relevant for this code?
    Kind regards,

  17. Wilko • 04/30/2016 #

    Please accept my apologies, I believe I should go to bed instead of posting irrelevant questions. Anyway, thanks again for this post!

    • Nicolas • 04/30/2016 #

      Ahah, I’m not the author of this one 🙂
      I know you are a great coder Wilko, why don’t you post one or two of your findings? Hope to see content from you very soon 🙂

  18. Wilko • 04/30/2016 #

    Thanks for the flattery! I will, I promise. 

    • Nicolas • 04/30/2016 #

      Still don’t have seen anything from your own 🙂 You promised me! Ahaha 

Register or


avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
Ciccarelli Franco Hai ragione, mi dava valori alti perchè usavo questo loss "SET STP LOSS 1xAverageTrueRange{1...
YvesRobert Hello davidelaferla, how do you put a stop loss and where exactly ? the moment you enter on ...
Hypersimo Buongiorno Davide a quale distanza inserire stop loss e tp nella strategia? grazie
Meta Signals Pro great feature ^^
Meta Signals Pro can you detail how you did that or refer to a link ? thanks
JohnScher Short variant, see at
DANY Hi JohnScher, Thanks a lot for your contribution. Consider this release to avoid overfit...
JohnScher Thank you so much for exploring the Late Lunch Strategy. For discussion and in answer to yo...
BenJuice JohnScher, merci de partager ta stratégie. Je suis nouveau dans ce domaine, sur ton code q...
JohnScher As a percentage of the price, here 2%. StopLoss as well as TargetProfit. SL and TP come ...
Wilko I absolutely love the simplicity of this mean-reversion strategy. Well done!
Patrice210 bonjour STANKO, effectivement la première ligne apparait en anomalie et je ne comprend pas v...
KumoNoJuzza Hi guys, Thanks @Stanko and everyone for your contributions. I have been playing around ...
Stanko Hi KumoNoJuzza, thanks for the post. I also tried your code with Dax and the performance is ...
snucke i dont think you understod the question. i did not ask about the band pass indicator. i as...
thomas2004ch Hi, Is this startegy suitable for daily SPY? Regards
ebous64 Je cherche à traiter des effets de bords avec un encadrement ajustable des variables. Vous a...
JohnScher Postscript: It's running in the live right now. One position after the other is opened. ...
ullle73 nice!! how's it been since your last post on going live? :)
thomas2004ch Hi, Is this strategy suitable for daily SPY? Regards
wally Hola soy nuevo en el mudo robots. Alguien seria tan amable de poner el archivo itf.file ya q...
Darren Nash I found this works well on the DOW
thomas2004ch Hi John, Is your strategy suitable for daily SPY? Regards
cdc.andersson Hello, I´m trying to paste the code and start testing but can´t get it to work in PRT. Shoul...
Lupo32 Thank You Aaron
superfalcio I'm having no more issue on the new Prorealtime release 11.1
venugopal Hi Nicolas, Thanks for this code. Is it possible to build a screener using this indicator?. ...
Nicolas It has been done in that topic. Enjoy.
Abouadam2 EFFICACE
woktrade Superbe !
Vonasi An updated version with a bug fix can be found here:
snucke hey Vonasi is it possible you can help me get this indicator to show how much a market mo...
FXmike hey my friends, thank you for this great code. my problem is he make no trade open. backtest...
FXmike Can i put a Action that my start contract is smaller than 1 ? 0.3 or 0.5 ? In wich Position...
phoentzs I wrote the code for M15 back then and also variants in H1 and M1. Everything works so far....
Jan Wind Thanks for sharing ! The Gain/Loss ratio is a bit low, 1,16, hardly offset the risks take...
drive whats the period ?
Lucas0000 Hola. estoy buscando un programador en proorder, para hacer un programa basado en el Q-trend...
Ludwig Bonjour Merci pour le code, je souhaite intégrer un break even et mette en place un réinves...
superfalcio hello, this strategy is pretty interesting, anyway on index after diferent suggestion and im...
Fralex Hello everyone I optimized the original “LongOnly-DAX-4H-TMA-Channel” algorithm over a pe...
Dom Hello, commence le trading et découvre par la même occasion le ce n...
Nicolas Merci, ça fait plaisir !
Be-n Bonjour tout le monde ! Dans l'indicateur de tendance, j'ai du mal à saisir la nuance entre ...
YvesRobert @robertogozzi. It's done. Thank you
YvesRobert Hello Roberto, some questions about your strategy. 1 - Do the 2 lines SET TARGET pPROFIT T...
robertogozzi 1. The 2 lines SET TARGET pPROFIT TP and SET STOP pLOSS SL are always executed, each bar. Bu...
Anonymous Hi robertogozzi - thank you very much for sharing this strategy. I have performed various ...
robertogozzi Thank you samsampop.
Dotan Hello guys I really appreciate this coding effort but can I use this code for Mt5 Forex Trad...