S&P 500 mean reverting strategy

S&P 500 mean reverting strategy

Dear all,

pls enjoy this little code which gives very nice results on S&P 500.

There are only 2 variables optimized (the bollinger bands and the moving average periods) , can work with several underlying.

Best regards

Francesco

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. Giorgio Ravagnani • 09/13/2017 #

    Hi Francesco,
    I’m Giorgio nice to meet you, I’ve been following you and your work for some time and i think that are really interesting what you are doing, can you explane me how does it function? I’m little confused about the operation

    Thanks so much

  2. Francesco78 • 09/13/2017 #

    Hi Giorgio! thank you. Relatively to this last strategy, it simpli take long or short position if the candle is fully above or below the bolliger band defined by bperiod and it closes the position when the price touches the average defined by averageperiod. Hope this help

  3. Giorgio Ravagnani • 09/13/2017 #

    Do you test it on a Demo or Real account?

  4. Francesco78 • 09/13/2017 #

    real. I never used a demo account.

  5. Giorgio Ravagnani • 09/13/2017 #

    I prefer test a strategy for a while but i understand your point of you.. When you decide to stop the system? When it exceed the max drawdawn of the backtest?

  6. rejo007 • 09/13/2017 #

    on backtest since 2007, i don’t have very good results.
    (i could’nt attach a file here)
    you have the same?
    thanks

  7. Francesco78 • 09/13/2017 #

    hi Rejo007. I havent tested since 2007 but I am not surpised that this stratrgy doesnt perform well im 2007 2008 and 2009 as they were very trendy. As a general rule I think one should have in the portfolio a combination of strategies, some mean reverting and some breakout

  8. robdav • 09/13/2017 #

    Hi Francesco,

    Just out of interest, do you run this live?

    If so, what period of data do you back test/walk forward it over to optimise the settings?

    How often do you re-tune it?

    Many thanks

    Rob

  9. Francesco78 • 09/13/2017 #

    Hi robdav, yes Im running it live since I posted it. Backtest/WF was for the last 3 years. I havent re tune it, I think I will do so every 6 months

  10. robdav • 09/13/2017 #

    Thanks Francesco, interesting.

  11. stefou102 • 09/13/2017 #

    I came up with a pretty similar strategy, although in my experience the following test works better:

    GoShort= close[1] > BolUp and open > BolUp and close < Bolup
    GoLong=close[1] < BolDown and open Boldown

    Any other ideas of filters to improve this?

  12. Wilko • 09/13/2017 #

    The close at MA condition does’t make much sense as this strategy will stay in market until a position is opened in the opposite direction. Try changing the exit condition to for long positions CLOSE > BOLLup and for short positions CLOSE < BOLLdown. This will give similar results to the original strategy.

    In my opinion this is the typical kind of strategy that has benefitted from the combination of QE and increased algorithmic trading activity in markets. The latter provides added short-term liquidity to market while QE adds long-term liquidity, the combination contributing to a trend towards lower risk premia. I would not want to keep trading this strategy when global QE reverses, or when global economic growth stutters.

    Many thanks for an interesting contribution! It did challenge me to some exploratory work.

    • Aaron Bennett • 09/13/2017 #

      Nice analysis, with the proposed tweak I’m seeing great performance since 2008/QE on the CAC40 Daily; not so good prior to that.

  13. danibo • 09/13/2017 #

    Hi Francesco,
    please may you explain how to reproduce your test?

    I use IG markets. Where your data come from? Also you use US 500 DFB but I can find US 550 CFD standard only. Is you TS expected to behave the same way with that?
    Thank you

    Danibo

    • Francesco78 • 09/13/2017 #

      Hi Danibo, I am not sure I undesrtand your question, you simply need to run a backtest on PRT using US 500 CFD. I am using a uk version of IG but you will find the same index on every platform.

  14. danibo • 09/13/2017 #

    Hi Francesco, thank you for replying.

    I try to be crearer. My question is:
    – what is the spread you use in backtest?
    – why can you use US 500 DFB while I can see just US 500 CFD?

    Thank you

  15. JanWd • 09/13/2017 #

    Hi Francesco, nice algorithme, works with me on other markets as well !

  16. Francesco78 • 09/13/2017 #

    thank you Janwd. Do you mind sharing where it works? happy new year!

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar

+11 more likes

Related users ' posts
Vinks_o_7 Thanks Doc !
Maxime Baudin Intresting, thank you!
Zigo Normaly it do work in version 11.
bertrandpinoy Hello to all, please does a coder can bring the indication of the price level on the chart o...
Zigo @bertrandpinoy add between line 50 and 51 : drawtext("#dnh#",barindex,low-2.618*AverageTrue...
Franro Hi, this looks very good is this something you worked towards a strategy?
hua hin Bonjour comment mettre ce programme sur un graphique le lien est en JPG et sur crewation i...
Dron Hola! El archivo itf donde esta?
Bard I've also just noticed that changing the "Bands Deviation" setting from 1.25 to eg 3 doesn't...
bartekz Hi @Nicolas, Really impressed by your work. I am trying to replicate the Wave-PM indicator t...
Nicolas You don't have to replicate it, download the file and import it into your platform.
Marie-Eve Vergoz lorsque je copie les codes, le système me signale des erreurs à la ligne 12 et suivantes
Marie-Eve Vergoz sorry - tout est ok -
jobswaps Sube como trazar lineas de tendencias a tantas barras
Frankiesc interesting indicator !! Thanks for sharing!!!
robertogozzi Thank you :)
JJ Tec Hola Las condiciones de entrada / salida vienen en el libro de J. Carter Mastering the trad...
Pixeldd Ich bekomme beim einfügen des Indikators einen Fehler angezeigt. Was bitte muss ich genau än...
HarryPro Hello, Firtly there appears to be a typo on line 6 "lenghkc=20" should this be "lengthkc=...
Nicolas En effet merci, erreur corrigée, la variable Risk affecte désormais comme il se doit les cal...
nader003 How can we get this indicator on MT4
Nicolas You can ask for private custom coding to our programming services: https://www.prorealcode.c...
arnaudat Merci nicolas, j'ai déjà pris cette version et en plus je suis sur les futures. Par contre d...
ullle73 hi nicolas, when im making a strategy out of this i get the error "PRC_VWAP z-score" called ...
Nicolas Please open a new topic in the ProOrder forum section and post the code there in order to ch...
lokbuscas is it possible to make a screener with this conditions??? thank you
achel I believe so but I leave it to Nicolas to decide if it is possible
Nicolas Please open a new topic in the screeners forum
Gianluca Hello Nicolas, my prt become stuck when i load the indicator, is there any problem with it?
m-zeter Has anyone found a solution for Sofitech? Would it be possible to draw two lines? An upper l...
m-zeter Hm, i dont know exactly why, but I think, that the indicator needs lots of power. I need als...
Leo Does it opens pending orders?... maybe they were not trigger.
Mattzi Dont know, all i can see is that it opened an order yesterday in backtest but not live. Th...
Jean-Christophe Hello Leo, when running the strategy from 29/12/2015 to 31/08/2018 on ProRealTime Premium, I...
anametsinwha Is it possible to change it to highs and lows rather than open and close?
apachx Hi. Please, describe the algorithm in words. I want to understand how it works, but for now...
juanj This gets me thinking about creating a strategy on the 5min timeframe that only takes trades...
GraHal I noted above does okay on DAX 10 min with even a reduction to 30 of the Stop Loss. I've s...
Kris75 Hi Grahal, What about making the same great work you did with the snipet on google doc but...
LancerX This catch my attention, tried to load in pro order but not coming through. What variables n...
macdopa Hello ALE. Is there any way to help us develop or program an algo-strategy for automatic tr...
Giuseppe68 Ciao, sono nuovo e poco esperto, volevo chiedere perchè il ProBacktest lo esegue correttamen...
Alai-n Merci pour ce travail...
patmaba merci Alai-n. C'est ma première participation sur prorealcode, merci pour à toi pour ton co...
longtrade Can this be converted to a screener?
Madrosat Bonjour Nicolas la formule du stop loss est elle vraiment valable ?? il n'y a pas au depart ...
Nicolas Il y a peut-être un erreur en effet, essayer avec: set stop ploss (averagetruerange[14] * ...
Madrosat ok merci Nicolas c'est avec /pipsize que ça fonctionne

Top