Oil 15 minutes meanreverting strategy

Forums ProRealTime English forum ProOrder support Oil 15 minutes meanreverting strategy

This topic contains 48 replies, has 13 voices, and was last updated by avatar stockdemon 9 months, 2 weeks ago.

View all attachments
Viewing 15 posts - 1 through 15 (of 49 total)
  • #43014

    Hello, I created this thread after the contribution of Juan Salas.


    Juan, can you please post here your results and your code?

    Many thanks!



    Hi Francesco,

    Thanks. I am attaching the code:


    7 users thanked author for this post.

    I am also attaching pics of my backtest:

    4 users thanked author for this post.

    As you can see in the code, the parameters trailingstart: 25 and trailingstep: 30 determine the following:

    Trailing start is the first profit locked. Once 25 is secure, the trailing will be securing profits after every 30 pips (trailing step). You can play with these two parameters and decide which one fits you better.

    I hope it can be useful. I already mentioned, but I am a big fan of your hammer-negated and mean-reverting, so I have taken the liberty to customised both codes.

    I am trying to see if mean-reverting is adaptable to any other instruments (Indexes, Forex, etc).




    1 user thanked author for this post.

    I am at the airport right now, so I will try to post (maybe this weekend, or beginning of next week) results and codes for the hammer-negated in other TFs.

    Have a great weekend,


    1 user thanked author for this post.

    Thank you Juan Salas!

    have a safe flight 🙂


    Hey guys, can anyone explain the logic behind the exit? Are you creating a target around 35 points? I’m referring to this part of the code:




    Hi, actually, the exit is defined by the trailing-start and trailing-step.

    These two paragraphs in Spanish salida largos/Exit long and salida cortos=exit short are somehow something I thought it would help to mitigate the losses. I shouldn’t have labeled it as exit long/short.

    In this sense, what I have tried to code is that because the Stop Loss is 90, I wanted to avoid to reach 90 in cases when is clear the operation is going to be negative. Example: when a LONG operation is losing by 35 points (enrojoalcista) and on top of that we see we have a long short candle of more than 30 pips, we sell at market. The market is showing a clear SHORT tendency, so why wait??. It is a little simple but it works in most of the cases. When operating in manual, if you see this clear short tendency, you would cut the losses. The same way, I wanted to create these two conditions to avoid reaching the stop loss of 90. In some cases, I am sure the operation would turn around and would close in positive, but are IMO the least.

    I hope it clarify these two paragraphs,



    P.S.- If any of you have tried this code in other values, it would be nice to share. I think Francesco did a wonderful job with hammer-negated and mean-reverting and we should try to explote these codes in other values and TFs.

    3 users thanked author for this post.

    Hi Juan,

    Thanks for your explanation. I think you have a great idea and I’ll try this section of code on other systems. With regards to this system I was a little bit bothered about the short history so I tried to see if the idea works on a higher timeframe just for some better confirmation. I have attached my version of the US Crude 1H. Please not that this backtest is curve fitted and should be adjusted before trying out live. It’s more to get an understanding if the idea works well. I would also like to point out that the return on this system (even if it’s not bad) is not as good as the one on 15 min.

    1. Candlefullness-crude-1H.itf

    It is so annoying that we have so little data for oil. There is plenty for several other raws but on Oil one has to go up to daily timeframe to get more data. 🙁


    @nicolas: I think something is wrong with the forum. I tried now several times to attach a file but it doesn’t show up and obviously Victor had the same problem. His file(s) don’t show.


    Hi Victor,

    Thanks. I will try on US Crude 1h and will see the results. In any case thanks for Francesco’s and your understanding. I just got into PRC three months ago and learning everyday from all of you guys.

    BTW, I am seeing the expressions “curve fitted” a lot, and although I know is about the equity curve, I don’t know exactly the meaning of the expression when it comes to the performance of the EC. Any explanation would be greatly appreciated.




    Hi Juan,

    Thanks for your contribution.

    Curve  fitting is a very big issue when developing strategies. In short it is adding too many rules to your code to make the backtest look better and better. Think of the extrem. You could code a strategy that specifies for every trades of the past exactly when it should be opened and closed. You could easily construct a backtest with 100% winning trades. But this strategy obviously has zero predictive power and putting it live would most likely only lose money.

    2 users thanked author for this post.

    Hi Despair,

    Thanks for the explanation. I am afraid that I did what you said with some of the strategies, and when I put them on DEMO I noticed some discrepancies with the performance of my previous backtest, so I thought that I have adapted the code to create a clean curve on the backtest. You just confirmed my original idea, but I had no idea that it was labeled with the expression “curve fitted”. Besides the name, it is good to know that when working on strategies and adapting other systems is not about constructing the perfect curve.




    Curve fitting is the probably the nb. 1 reason why realtime trading results differ from the backtest. The best we can da right now is utilizing WFA. I made a post not long ago labeled “WFA – Am I doing it right?” (post # 42252). This is a very short description of the way I think with my current knowledge one should optimize a strategy.

    2 users thanked author for this post.
Viewing 15 posts - 1 through 15 (of 49 total)

Create your free account now and post your request to benefit from the help of the community
Register or