Oil 15 minutes meanreverting strategy

Oil 15 minutes meanreverting strategy

Hello,

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

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. Wilko • 06/28/2017 #

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

  2. Francesco78 • 06/28/2017 #

    Thank you Wilko!

  3. victormork • 06/28/2017 #

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

  4. alexinvestgroup • 06/28/2017 #

    What spread?

  5. Francesco78 • 06/28/2017 #

    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 • 06/28/2017 #

    Alexinvestgroup, I have used spread = 1 to backtest

  7. Yannick • 06/28/2017 #

    Hi thanks for sharing.
    Did you tried volatility take profit and stop loss based on atr rather than fixed values?

  8. Kenneth Kvistad • 06/28/2017 #

    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 • 06/28/2017 #

    Kenneth, it means that the tick value is 1 euro

  10. Kenneth Kvistad • 06/28/2017 #

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

  11. Juan Salas • 06/28/2017 #

    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 • 06/28/2017 #

    //————————————————————————-
    // 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
    ELSE
    tradeok = 1
    ENDIF
    // Friday 22:00 Close ALL operations.
    IF DayOfWeek = 5 AND time = 220000 THEN
    SELL AT MARKET
    EXITSHORT AT MARKET
    ENDIF

    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 avfullnessthreshold

    // Largos
    IF NOT ONMARKET AND cl AND tradeok=1 AND NOT Fridaynight THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF

    // Cortos
    IF NOT ONMARKET AND cs AND tradeok=1 AND NOT Fridaynight THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF

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

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

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

    //stop order to exit the positions
    IF newSL>0 and tradeok=1 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    //************************************************************************

    //set target pprofit 30
    set stop ploss 90

  13. Juan Salas • 06/28/2017 #

    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 • 06/28/2017 #

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

  15. Francesco78 • 06/28/2017 #

    Thank you Juan Salas!, will have a look now

  16. Francesco78 • 06/28/2017 #

    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?
    https://www.prorealcode.com/topic/oil-15-minutes-meanreverting-strategy/
    Many thanks!

  17. Francesco78 • 06/28/2017 #

    how do you define trailingstep and trailingstart?

  18. stockdemon • 06/28/2017 #

    Posted solution to the zero div problem which exists in the different versions of the code.

  19. lizmerrill • 06/28/2017 #

    can you explain the flow of the code, just to clarify. RE:fullness = (Dclose(0)-Dopen(0))/abs(Dhigh(0)-Dlow(0))
    avfullness = summation[period](fullness)/period. Correct me, but avfullness is based on the dailystats, e.g., dclose, dhigh, dopen,dlow. Since you are using 0 for parameter for dclose(0), and dhigh,dlow,dopen, I assume that during the 24 hour day, these values will change, is that correct, so there fullness will change, as the day proceeds, is that correct?

  20. Francesco78 • 06/28/2017 #

    hi Lizmerril, yes, that is correct

  21. lizmerrill • 06/28/2017 #

    Thanks for replying, so…. I assume in your backtest, the fullness calculations using dclose,dopen, etc were based on the last available prices i.e., the open, h,l, and close of daily frame from yesterday, right?

  22. DANY • 06/28/2017 #

    overfit

  23. fatlung • 06/28/2017 #

    Excuse me. I would like to the time zone applied to this strategy.

  24. UkCoopDownUnder • 06/28/2017 #

    Hi,
    ProOrder does not recognise, “avfullnessthreshold”
    any ideas, thanks

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
f1_maik Well programmed, but in my eyes ‘only’ better Bollinger Bands with all their quirks and fals...
groelandes Me uno al comentario de Edelmiro. Un millón de gracias por el trabajo constante, dándonos in...
JohnScher Ja, das würde mich auch interessieren
Patrice210 bonjour STANKO, effectivement la première ligne apparait en anomalie et je ne comprend pas v...
KumoNoJuzza Hi guys, Thanks @Stanko and everyone for your contributions. I have been playing around ...
Stanko Hi KumoNoJuzza, thanks for the post. I also tried your code with Dax and the performance is ...
kbrooks323 Hello would someone be willing to release a scan code for this? that would be helpful as I s...
Nicolas You can do easily this screener by using the assisted creation tool. It would take you about...
kbrooks323 I just figured it out thanks!
Vinks_o_7 Thanks Doc !
Maxime Baudin Intresting, thank you!
Peter I recognized a possible problem with the timeframe / Defparam variables. As far as I know, t...
superfalcio Hello Peter, it is long time i have been watching this strategy, very good and interesting ...
Peter I indeed do have different modified strategies in the market. In the past my variants perfor...
ggolfet Thanks Nicolas, I imported the itf file and solved the problem.
Hasardeur Hallo Nicolas, i tried to code the multi period heat map in combination with the Ehler’s ...
Nicolas Please open a new topic with the code in forum.
sir_i Bonjour à tous, Je suis nouveau sur le forum et sur la plateforme, pourriez-vous me dire com...
Nicolas Il faut simplement l'appliquer sur le prix.
sir_i Merci pour la réponse, je ne suis pas familier avec l'application de cette procédure simple,...
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...
3agl3 voglio l indicatore
abd78 @Vonasi I saw that you did some work on seasonality, I wondered if you wanted to go here and...
Vonasi Sorry - my understanding of Italian is zero so if I watch the video I won't understand it I'...
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...
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...
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
Francesco78 @snucke the results are not the same because the pictures refers to a few years ago. I am no...
snucke @Francesco78 i mean the results differ when i test on my own. so im curious of what the p...
sfl still working, using with filters like : trendFilterUp=close>average[190](close) tren...
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...
Nicolas No sorry, please use this file instead into a prorealtime trading platform.
rdabbs I just installed this indicator. It opens in its own pane rather than overlaid on the chart ...
Nicolas Just apply it on your price chart instead and you're ok.
andreag76 Thank you Francesco78 !
juanj What happened after August 21?
jpgcreatestrading Hi Manel, i have found this same issue, some strategies (but not all) that are written with ...
Wilko I am not familiar with the screener function, but I am quite certain it should be quite simp...
Gubben @Wilko have you had a look at this again since MTF support? Heard you talk on Börssnack btw..
Wilko @Gubben not really. It was something I posted to show that simpler is usually better. Hope y...

Top