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?

New! PRC is also now 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. david-1984 • 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. david-1984 • 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. david-1984 • 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. david-1984 • 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. david-1984 • 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. david-1984 • 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
Nicolas Use the color variables R and G to test if the trend is bullish (R=0) or bearish (R>0).
s00071609 Where can i find the syntax to test the colour of the line, I am calling the indicator value...
Nicolas You should open a new topic to discuss about the strategy and its coding.
10 months 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.
kuroobi Parfait , merci beaucoup .
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...
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.
Nicolas Des nouvelles ?
Whisper74 Hi Nicolas, I have build supertrend in excel for research and database purposes, but I actua...
Nicolas Sorry, I can afford to make custom programming for everyone. If you want to have codes trans...
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 Have you ever made any Franc with trading ? I guess, not. Maybe I should change business and...
Nicolas Everything here is free, I do not sell anything and "tell people what they like to hear", I'...
verdi55 Is there such a thing as a free lunch ?
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 ...
Elsborgtrading Hi Triss. the File is in the post for download. There is nothing wrong with the code. Your e...
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 ...
DANY I did it on demo account; it's too dangerous for mea and I can not resist psychologically  ....
demoz How can a demo account be dangerous? Did you have it run live (on a demo account for exampl...
DANY Yes, I mean that I tried on a demo account for 2 months and it had work fine, like the BackT...
MikeGC I don't know if you have used the variables a and b to optimise the parameters for the Super...
gianpiero75 I have not optimized, I multiplied the parameters for 6 (5,8), to use them on the 4  hoursTF...
bertrandpinoy bonjour Mike j utilise TrendChaser V2.0 et quand il prend position cela ne programme pas le ...
Nicolas Yes, colouring background by code is only available in the version 10.3. with the instructio...
ludo7769 Hello , J'ai la version 10.2 et ca ne marche pas, qu'est ce qui coince ?  Merci a vous 
eisi If i switch between different Markets, the Backgroundcolour will appear where it should not...
4 years ago
gianlox What markets did you feel ? Thanks..
wanjpt Doctrading, could you code an alert when the supertrend touches price for various timeframes...
JSTAR PRODUCTIONS Hi there DocTrading, I have run this Screener and it only seems to screem When trend line to...
4 years ago
Nicolas Exit and relaunch PRT should fix this behavior.
verdi55 Thank you. After a restart, it is somewhat faster; however, it still takes about 3 minutes t...
Nicolas Good! thanks for sharing your own code! Please do so with other ones if you think you can im...