Supertrend… Against the trend

Supertrend… Against the trend

Hi all, I’ve tried with one friend to create a TS that is robust and could work on different index.

Here is a trading strategy to be run on 1 hour time-frame.


Long entry if supertrend is short and the price goes over the EMA. Closing under the Bollinger bands middle.

Exit long if supertrend is long and the price goes under the EMA and the closure is under the Bollinger bands middle.


Only thing to be chosen before run the backtest is the number of contracts, the starting time and end time.

The starting and end time is there to avoid to insert orders when spread during night time is too high.


For DAX, EUROSTOX, CAC I suggest starting time 8 and end time 22.

For MIB I suggest starting time 8 and end time 18.

For GOLD and WTI starting time 0 and end time 24 (spread is always the same).


Is there someone that can do a montecarlo forward test on this code?

any comments or Idea? I have also a version with money management but that would be a second step.


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. Nicolas • 05/23/2016 #

    Hi David, thanks for sharing your strategy. Your contribution is much appreciated. Hope you’ll get what you are looking for into automated trading 🙂

  2. avatar
    Anonymous • 05/23/2016 #

    Probably a lot of people will see the trend line and think that it is not soo good compered with other trend line in this forum but please try to run it on other index also. It is there that you have good performance!

    • Nicolas • 05/23/2016 #

      Straight equity curve line is a trap, as we already discussed david. I’ll have a look on this code with my MonteCarlo matrix.

  3. Doctrading • 05/23/2016 #

    On prorealtime CFD, you can test the strategy since May 2006.The results are interesting.
    It’s winning since 2009, with a drawdown from August 2013 to December 2014.
    Thanks for sharing.Regards,

  4. avatar
    Anonymous • 05/23/2016 #

    Hi Nicolas! thanks for testing with montecarlo!! I think that best index to use are CAC WTI MIB and DAX. I am running it on test IG to see if real orders are like the backtested and for the moment it seems like this. If you will think that the system could be good I will share another code to avoid exit during the night for those index with increasing of the spread. Let me know if you want me to change the code in english… I saw only now that it is in italian. Sorry.
    Hi have another setup for this that was the original one:
    mm = 10
    BB = 20
    ATRvolaDown = 10
    ATRvolaUp = 40
    ATR = 14
    x = 2
    supertrendLow = 3
    SupertrendUp = 10
    These parameters should not have any curve fitted problems…
    @doctortrading… any suggestions to improve it?

    • Nicolas • 05/23/2016 #

      Default indicators periods tend to be less curve-fitted you’re right, since these are the most used ones in the past and surely be in the future by the masses.

    • Gustaf • 05/23/2016 #

      Hi David!This looks really interesting. I’m a beginner, and unforunately I don’t understand italian.I Would greatly appreciate if you could translate the comments into english, as it would help me to get new ideas on how to create systems of my own.Keep it up!

  5. avatar
    Anonymous • 05/23/2016 #

    You are right Nicholas… this is why I have not choosen yet which of these 2 sets of paramenter should be used. We have to remember that the curve fitted could it be done also on multiple indexes and not only one.
    The forward test could give us some better idea.

  6. avatar
    Anonymous • 05/23/2016 #

    As said at the beginning this TS should not be run in only one Index. In the image in the link you can find the profit line of MIB,CAC, GOLD, DAX, EUROSTOCK all togheter. These lines consider the spread already!

  7. Nicolas • 05/23/2016 #

    For everyone information this strategy is also discussed in the forums on this thread:

  8. davidp13 • 05/23/2016 #

    Hi David. First question is why do you enter LONG if price is below the SuperTrend? And comment is have you tried ADX as an entry filter?

  9. avatar
    Anonymous • 05/23/2016 #

    We try to enter before that the market actually turn. We try to anticipate it. In which way would you use ADX?

  10. dwgfx • 05/23/2016 #

    David-1984 are you saying that you’ve already factored in the spread within the code? 
    If yes, where have you done that?

  11. avatar
    Anonymous • 05/23/2016 #

    no, not in teh code… only in the backtest. The entry is only between 8/22 so the spread for dax is 1 for most of the trades and 2 for the ones after 18.00 and before 22.00

Register or


avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
1 month ago
Iván I personally like it in daily timeframe
oliTR Many thanks Ivan, I copy/paste your code to try it but could only get a constant stable unif...
Iván Hi, I've copied the code above and it works... what asset are you trying? $indices array ...
2 months ago
Madrosat Hello Ivan You have interesting topics on indicators , smart supertrend, optimised trend t...
Iván Hi! thanks. All of these codes are translations requested in the forum. I've on mind to back...
Raspete01 Buenos días Iván, estoy intentando llevar el código eliminando los colores y pasando un Back...
sfl Removing the short side will help, I would like to know from the author where are the condit...
WE ARE SOCIETY DEFPARAM cumulateOrders = False rem CAC40 (france40) en 10 secondes rem à la ligne ci-dess...
David Daget Bonjour. A noter que cette stratégie fonctionne aussi sur le ftse. Ce qui n'est pas surprena...
Nicolas Simple strategy with this indicator is available here:
FXtonio Nicolas.... MERCI 1 millions de fois, cet indicateur gagne dans 75% des cas en scalping m1 ...
davy42 bonjour, à quel moment apparait le fleche, à l'ouverture ou la fermeture de la bougie? merci
10 months ago
AndPar Buongiorno Nicolas, vorrei provare questo indicatore, ma quando lo inserisco in PRT mi vengo...
Nicolas Basta aggiungerlo al prezzo
Aragorna hello Nicolas, this indicator works with the last Beta version of PRT? Ive seen tha many in...
mickey992 salut merci pour ton partage et ton travaille
patapouf Hi Vivien René I just discovered your “Ordered trend-following stocks Screener”. Great work...
Nicolas Oui le code est correct et il fonctionne, j'ai de bons résultats sur la liste NASDAQ par exe...
pincherman Bonjour :-) J'ai coller le script dans prorealtime pour jouer avec le supertrend et j'ai un...
Nicolas Vous l'avez sans doute collé au mauvais endroit, dans l'éditeur de code pour les stratégies,...
Nicolas Just add it on the price series.
yomisadiku Hello Nicolas, Can I use high and low price at lines hh=max(hh,close) and ll=min(ll,close) ...
Nicolas Yes you can do that, the impact will be that the trailing stop line will be much close to th...
5 years ago
Marcot18 Alex ti sei superato
AlexF Esagerato!
SL Hi, Fer666 Thank you for sharing. If I want to show daily ST on a 10_min intraday chart...
SL correction above... system had remove"not equal" signs Line 19 : change to if WeekNo "Not...
SL OK... I had figured out... need more than that. Thank you anyway.
Juan Salas Hi FULVIO09, Nice piece of work. It seems to work very well. Does only work for INDEXES??...
Johann Hi @FULVI09, I understand the instructions however I'm not too sure how to determine the "p...
Player8520 Hello, It doesn't work with me either. However, I changed AA to 180 on line 15, added th...
Geronima Ortiz I watched the video three times, but I can not put the npips parameter as a variable. I do...
Geronima Ortiz I think the video is for an old version of prorealtime, the images do not correspond at all ...
Nicolas indicator1 = CALL “PRC_StopReversal”[npips, 1] and define npips in the optimization window ...
Caribeengeek Bonjour j’avais vu que vous proposiez d’écrire des codes pour ceux qui s’y connaisse pas Mai...
Caribeengeek Les devises unité
Nicolas Merci d'utiliser le forum pour les demandes de programmation personnalisée
verdi55 You can find me at Ahh. So i got it ? 4 different supertrends without th...
juanj What? This has nothing to do with the website. The site is simply a service to help people ...
Nicolas Advertising is allowed,as long as people are helping others and if provided services are abo...
jebus89 Big thanks for sharing this :) Seems to work as expected, good stuff.
WarningTrading Comment peut on la comparer ? comme ceci ? cela ne me donne plus le message d'erreur manque...
sally31120 Bonjour, je n'arrive pas à créer ce screener close > supertrend extended2[1] la réponse...
Nicolas voir ce sujet pour un screener basé sur Supertrend Extended:
Nicolas Indeed, if you are not willing to loose, you will always win. Averaging down losers can carr...
David You're always safer going Long especially with averaging down on an index as the probability...
Oskar Bergvall  I noted Davids and Nicolas remarks. Could it be possible to make an indicator for contraria...
verdi55 Is there such a thing as a free lunch ?
maceng Thanks Nicolas for this great work! I would like to understand the math behind it in order t...
Nicolas Sorry I have no time to provide assistance for python programmers. Have a good day.
Nicolas You need to have enough bars loaded on your chart for the indicator to compute completely th...
verdi55 Working with separately calculated supertrend indicators in backtests is usually somewhat pr...
Nicolas Very interesting Verdi. Would be a great addition to the library, your own modified version ...