M15 SP500 LowBuyHighSell

M15 SP500 LowBuyHighSell

Here is a strategy on the SP500, which in its raw version is already effective long and short. With similar settings the code is also effective on other indexes.
It is a mixture of gap close and mean reversion. We buy intraday below a low from the daily chart. We are selling above a high from the daily chart. The exit is the close of the previous day. So theoretically a gap closure. We exit open positions every evening and are flat overnight. A simple stoploss based on the daily range is also included in the algo. That’s all. Improvements and/or thoughts on this algo are always welcome.

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. BigDaddyMrDo • 215 days ago #

    Very nice. I optimised the main variables over different years, then forward tested and back tested. It seems to be quite robust in most conditions.

    Something I added that made sense to me, was a time of day to stop opening any new positions. I set this to 150000 (UTC), which allows time for trades to play out before the end of the day.

    It also seemed to be more profitable in most conditions to carry the trade overnight. It’s nice to close out at the end of day but since we’re only in the market around 6% of the time and we carry over even less than that, the overnight funding costs are relatively low.

    Thanks for sharing, this is an interesting strategy,

  2. phoentzs • 209 days ago #

    I was impressed by the robustness of the strategy. You can really only optimize individual years or even quarters and then test over the rest of the time… You don’t have any big negative surprises, which I really like. I chose the time window from 8:00 a.m. to 9:00 p.m., i.e. the maximum so as not to over-optimize. You can certainly reduce the time window if there are improvements. You can also increase the number of trades per day… but then the drawdown will be more uncomfortable.

  3. virtuallyt23 • 207 days ago #

    Thanks for sharing. Could you tell why you’ve chosen 3 days period for Long trade but 13 days instead for Short ?

  4. Gio56 • 189 days ago #

    merci pour ce code.
    j’ai juste un problème sur le code, j’ai un message “L’instruction “Graph” ne peut pas être utilisée en trading automatique” en le passant en réel, alors que en backtest cela fonctionne.
    Quelqu’un sais comment résoudre le problème? merci.

    • Nicolas • 188 days ago #

      Il faut supprimer cette ligne qui est utile uniquement pour visualiser des valeurs durant les backtests.

  5. Gio56 • 187 days ago #

    Super merci Nicolas cela fonctionne. Top

  6. banjoo78 • 45 days ago #

    Which is the timezone’s setting of USA SP 500? I’ve differents results and I don’t know why… sorry

    • pdrh • 3 days ago #

      I have runit in the UTC+2 TZ and got matching results

Register or


avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
jens_kittner Since 2018 this strategy leads to bankruptcy)))))))
Jan Wind You do not HAVE to run it
Brisvegas As an exersize in writing code its fine but as a tool to make money not so much . If you hap...
JanWd Hi Francesco, nice algorithme, works with me on other markets as well !
Francesco78 thank you Janwd. Do you mind sharing where it works? happy new year!
Aaron Bennett Nice analysis, with the proposed tweak I'm seeing great performance since 2008/QE on the CAC...
EchnatonX Hallo Im Demomodus bei IG habe ich das Problem, dass oft keine Orders ausgeführt werden kön...
Jan EchnatonX, nice late answer of me: Make the stop loss a percentage of the close, like 100/...
guleny Hello I made some optimization to make it better. But there are 5 transacttion which incr...
Doctrading AH ok, I think the ca3 is the same : ca3 = pB[1] < 0.2 and pB < 0.2 Best regards,
chromosome21 Hello everybody, First, thank you so much for all your advices, I'm a begginer in trading a...
bertrandpinoy bonjour j ai un probleme avec ce code modifié, apparement PRT ne veut pas...avez vous une so...
Iber0 Asi quedaria con el spread de IG [IMG]http://i65.tinypic.com/2418ism.jpg[/IMG]
bjoern Seems to work nice on BUND - M15 with SL 70 and TP 120
hvluthy@sunrise.ch I tried to backtest this code but don't get any restults. Can any body help me?
CKW  Thanks Doctrading for sharing Is this Daily Time frame?  
Doctrading Hello, Yes, it is daily timeframe.
air Good job.