Oil 15 minutes meanreverting strategy

Oil 15 minutes meanreverting strategy


I found this nice and simple strategy playing with the “average fullness of last 5 candles” . I added a simple moving average oscillator, with 5 and 50 period and I considered mean reverting long/short condition by setting a threshold to the “average fullnes”

The strategy is really minimally optimized, I only optimized the threshold and the profit and stop target.

Results of  backtest and  WF are attached



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. Wilko • 87 days ago #

    Nice idea of relative fullness of candle! I like it.

  2. Francesco78 • 87 days ago #

    Thank you Wilko!

  3. victormork • 86 days ago #

    Nice work Francesco! Have you noticed that the long side is much better than the short?

  4. alexinvestgroup • 86 days ago #

    What spread?

  5. Francesco78 • 86 days ago #

    HI Victormonk, thank you, yes I noticed that. Maybe we could try to set different target for long and short to rebalance it, I tried to optimize as little as possible.

  6. Francesco78 • 86 days ago #

    Alexinvestgroup, I have used spread = 1 to backtest

  7. Yannick • 86 days ago #

    Hi thanks for sharing.

    Did you tried volatility take profit and stop loss based on atr rather than fixed values?

  8. Kenneth Kvistad • 86 days ago #

    What does buy 1 «perpoint» means?

    I also see there is some inside candlestick trades that i personaly have Never been able to be sucssessfull in.

    I see you have alot of great ideas and strategies 🙂


  9. Francesco78 • 85 days ago #

    Kenneth, it means that the tick value is 1 euro

  10. Kenneth Kvistad • 79 days ago #

    Francesco, can you try to make this strategy with short and long proffit tragets just like in your hammernegated strategy?

  11. Juan Salas • 43 days ago #

    Hi Francesco,

    I have customised your code for Oil USA 15′, applying Nicolas’ super trailing code (thanks Nicolas!) and other minor alterations (Increased STOP distance, closing operations Friday night, etc). The equity curve is a little smother and is working for me in real.

    I know it may not reflect a big change, but it very consistence and so far it is working very well. I am also a fan of the hammer negated. It is working for me in Oil USA in 10min, 30min, and …in 2 mins. The results are amazing. The only con, as well as with this code is that I have just tested it in 100k.

    I am trying to adapt the Mean Reverting to other markets, any suggestions would be greatly appreciated. (It is working well with Brent, but not as well as with the USA)

  12. Juan Salas • 43 days ago #

    // Código principal : MEANREVERTING w TRAIL15′
    //crude oil 15 min strategy

    DEFPARAM cumulateOrders = False

    // Dias de la semana
    IF DayOfWeek = 0 OR Dayofweek = 6 THEN
    tradeok = 0
    tradeok = 1
    // Friday 22:00 Close ALL operations.
    IF DayOfWeek = 5 AND time = 220000 THEN

    Fridaynight = Dayofweek = 5 AND time>220000

    //parameter definition
    period = 6
    fastav = average[4](close)
    slowav = average[50](close)
    maoscillator = fastav-slowav

    fullness = (Dclose(0)-Dopen(0))/abs(Dhigh(0)-Dlow(0))
    avfullness = summation[period](fullness)/period
    avfullnessthreshold = 0.38

    enrojoalcista= (tradeprice(1)-close)>35*pipsize
    enrojobajista= (close-tradeprice(1))>35*pipsize

    cl = maoscillator>0
    cl = cl and avfullness < -avfullnessthreshold cs = maoscillator<0 cs = cs and avfullness > avfullnessthreshold

    // Largos
    IF NOT ONMARKET AND cl AND tradeok=1 AND NOT Fridaynight THEN

    // Cortos
    IF NOT ONMARKET AND cs AND tradeok=1 AND NOT Fridaynight THEN

    // Salida Largos
    IF LONGONMARKET AND enrojoalcista AND (open-close)>=30*pipsize AND open>close THEN

    // Salida cortos
    IF SHORTONMARKET AND enrojobajista AND (close-open)>=30*pipsize AND open=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize

    //manage short positions
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize

    //stop order to exit the positions
    IF newSL>0 and tradeok=1 THEN

    //set target pprofit 30
    set stop ploss 90

  13. Juan Salas • 43 days ago #

    I was planning to insert pics of my backtest, but apparently I don’t find the way to insert a png. file in the conversation.

  14. Juan Salas • 43 days ago #

    By the way, thanks again for your valuable contribution to this community.

  15. Francesco78 • 43 days ago #

    Thank you Juan Salas!, will have a look now

  16. Francesco78 • 43 days ago #

    HI Juan, I created this forum where you can share with us your results if you dont mind.
    By the way your code as it is doesnt seems to work, can you pls upload the correct version in the forum at this link?
    Many thanks!

  17. Francesco78 • 43 days ago #

    how do you define trailingstep and trailingstart?

Register or


avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
robdav Hi Francesco, Just out of interest, do you run this live? If so, what period of data ...
Francesco78 Hi robdav, yes Im running it live since I posted it. Backtest/WF was for the last 3 years. I...
robdav Thanks Francesco, interesting.
Maz I like this
atlante je me demande si prorealtime pourrait etre programee sur fonction lorsquún point cgange de c...
rejo007 @francesco, i see you create a lot of strategy, thanks for your share. you test it all in ...
Francesco78 Hi rejo007, thank you, yes I have all of them live and manymore that I dont share. one of my...
rejo007 @francesco Thanks a lot, I'll take a look a this. Do you have strategy that you can share ...
Wilko I'm happy my code snippet inspired some new thoughts! Thanks for the feedback!
CKW Thanks Wilko. I modified your daily strategy to 4H and tested WF on Dow Jon with acceptable ...
Wilko Thanks!
diegofe_2000 cordial saludo NICOLAS , gracias por excelente indicador. ¿ es posible obtenerlo en MT4 ? ...
Nicolas Lo siento, pero no estoy trabajando para ayudar a la gente aquí de forma gratuita para promo...
diegofe_2000 Nicolas , gracias por tu atención. La pregunta era por curiosidad (yo no trabajo ni manejo ...
5 months ago
HerveS_67 Bonjour, A quoi correspondent les données S, M, L ? Hello, What do the data S, M, L?
gabri Excellent job like always!! are you working also on the Barycenter indicator?
Nicolas No but I think you can find a lot of different version of the "center of gravity - COG" indi...
Francesco78 Hi Juan Salas and thank you very much for your undeserved compliments. I'm not sure if I un...
Juan Salas Hi Francesco, Yes, this is pretty much the question. The system ask me a number of contract...
Francesco78 ok sounds good, you can put min size = 1 and go for the seasonable breakout too, also you ca...
David Nicolas I've looked at it again and there's a problem.  As an example here's a simple cross...
Nicolas You'll need to preload bars to get the good calculations of you indicators. I did not test i...
David Nicolas I tried DEFPARAM Preloadbars = 5000 And still the same drawn output of entries/exit...
Renato Di Lorenzo Agree; thanks.
rpreviteri Hi Nicolas, thanks a  loto for sharing your knowliedge, Wasn't the original momentum pinball...
air Thank you!  
Dimi.A Perfect for counter-trend scalping. I like this!
leyoy Bonjour, je viens de l'installer sur 10.3 ... comment faire apparaitre les flèches sur l'ind...
Nicolas Les flèches apparaissent d'elles-mêmes selon les signaux de l'indicateur.
leyoy Elles viennent d'apparaitre après redémarrage. Merci Nicolas. Du coup, les signaux sont à pr...
jctrader Bonjour . CAC 40    1988 = 1000   today = 4900  soit 490%  en buy and hold  .... + 370% av...
Nicolas Aucune immobilisation du capital. Quel est le drawdown du buy & hold ? Je ne l'ai pas ca...
jctrader ok pour le codage mais le choix "indice" n'est pas le bon : moins de 5%/an pour le meilleur ...
DonDollar ...and I do not see any opened positions...strange...
DonDollar I found the answer by myself for the second question. But still no idea about the False and ...
Nicolas The line 12 of the code is the answer of your question. Before launching a new trade, the co...
Nicolas I do not have any error Alfredo, even while testing on 150000 bars in the past. By the way, ...
alfredo thank for the council, when i do start the strategie on Italy at 1h some mornings happen tha...
Nicolas I think it's because of price gaps and/or quote interrupt. Anyway, be aware that this strate...