Discussing Matriciel EURUSD Dhigh Dlow

Viewing 15 posts - 76 through 90 (of 119 total)
  • Author
    Posts
  • #120034 quote
    valflare
    Participant
    New

    GOOD MORNING, I’M A NEOFITE AND I’M STARTING TO STUDY THIS TYPE OF TRADING.
    I TESTED THE STRATEGY IN THE ANNEX BUT IN REAL THE SYSTEM DID NOT CLOSE THE POSITION. WHAT COULD IT BE DUE TO? THANK YOU

    2020-02-20-M.png 2020-02-20-M.png 2020-02-20-L.png 2020-02-20-L.png EURCAD-DhighDlow-v1p-1.itf
    #120038 quote
    Vonasi
    Moderator
    Master

    valflare – Please don’t type in all capital letters. The use of capitals is considered as shouting in forums. In these forums you will find that code words will sometimes be typed in capital letters to highlight that they are different from normal text but otherwise we try to keep the shouting to a minimum! 🙂

    #120507 quote
    swedshare
    Participant
    Senior

    Hello gentlemen,

    I also made some modifications to this highly interesting EUR/CAD 15m strategy. Changes:

    • Changed spread to 2.5 since that is what IG uses on EUR/CAD.
    • Added a re-invest code found on this forum. It’s highly flexible, choose your own risk by adjusting the last line (I set 25 to default. 100 = 1 contract). Thank you creator of that code!
    • Lower stop loss (didn’t have effect on backtesting, just the illusion of lower risk and keep IG happy when go live).
    • Removed graphonprice to allow it to run on automatic trading in demo.

    As mentioned by the original creator Matriciel the time-in-market is i bit high which will add interest cost. But the % winning trades and gain/loss ratio is fabulous. It would be nice to not have a large MAE in almost every trade but I don’t know how to fix that 🙂

    // EURCAD Dhigh/Dlow v2 15m
    // spread 2.5
    
    defparam cumulateorders = false
    defparam preloadbars = 10000
    
    //
    once enablets = 1
    
    once select=2  // optimized for period1,2,3
    once tds   =1  // added on optimized results
    
    // code re-invest
    Capital = 10000
    Equity = Capital + StrategyProfit
    Position = Max(1, Equity * (1/Capital))
    Position = Round(Position*100)
    Position = Position/25
    
    if select=1 then    // TF 15 MIN
    tr1=45
    tr2=25
    period1=78
    period2=12
    period3=4
    elsif select=2 then // TF 15 MIN
    tr1=45
    tr2=20
    period1=84
    period2=6
    period3=8
    endif
    
    // trend detection
    if tds=0 then
    trendup=1
    trenddown=1
    else
    if tds=1 then
    trendup=(Average[tr1](close)>Average[tr1](close)[1])
    trenddown=(Average[tr2](close)<Average[tr2](close)[1])
    else
    if tds=2 then
    endif
    endif
    endif
    
    // strategy
    //ctime = time >= 000000 and time <= 220000
    
    mm = average[period1,3](totalprice)
    
    Newhighest=max(DHigh(0), DHigh(1))
    Newlowest=min(DLow(0), DLow(1))
    
    avghl = (Newhighest+Newlowest)/2
    
    c1 = average[period2,period3]((Newhighest+avghl)/2)
    c2 = average[period2,period3]((Newlowest+avghl)/2)
    
    condbuy = mm > c1
    condbuy = condbuy and close crosses over avghl
    condbuy = condbuy and trendup
    
    condsell = mm < c2
    condsell = condsell and close crosses under avghl
    condsell = condsell and trenddown
    
    //
    //if ctime then
    if condbuy then
    buy position contract at market
    endif
    if condsell then
    sellshort position contract at market
    endif
    //endif
    
    // trailing stop atr
    if enablets then
    //
    once steps=0                   // set to 0 to ignore steps
    once minatrdist=16
    
    once atrtrailingperiod    = 14 // atr parameter value
    once minstop              = 0  // minimum trailing stop distance
    
    if barindex=tradeindex then
    trailingstoplong     = 16   // trailing stop atr relative distance
    trailingstopshort    = 16   // trailing stop atr relative distance
    else
    if longonmarket then
    if prezzouscita>0 then
    if trailingstoplong>minatrdist then
    if prezzouscita>prezzouscita[1] then
    trailingstoplong=trailingstoplong
    else
    trailingstoplong=trailingstoplong-steps
    endif
    else
    trailingstoplong=minatrdist
    endif
    endif
    endif
    
    if shortonmarket then
    if prezzouscita>0 then
    if trailingstopshort>minatrdist then
    if prezzouscita<prezzouscita[1] then
    trailingstopshort=trailingstopshort
    else
    trailingstopshort=trailingstopshort-steps
    endif
    else
    trailingstopshort=minatrdist
    endif
    endif
    endif
    endif
    //
    atrtrail=averagetruerange[atrtrailingperiod]((close/1)*pipsize)
    trailingstartl=round(atrtrail*trailingstoplong)
    trailingstarts=round(atrtrail*trailingstopshort)
    tgl=trailingstartl
    tgs=trailingstarts
    if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
    maxprice=0
    minprice=close
    prezzouscita=0
    endif
    //
    if longonmarket then
    maxprice=max(maxprice,close)
    if maxprice-tradeprice(1)>=tgl*pointsize then
    if maxprice-tradeprice(1)>=minstop then
    prezzouscita=maxprice-tgl*pointsize
    else
    prezzouscita=maxprice-minstop*pointsize
    endif
    endif
    endif
    //
    if shortonmarket then
    minprice=min(minprice,close)
    if tradeprice(1)-minprice>=tgs*pointsize then
    if tradeprice(1)-minprice>=minstop then
    prezzouscita=minprice+tgs*pointsize
    else
    prezzouscita=minprice+minstop*pointsize
    endif
    endif
    endif
    //
    if longonmarket then
    if prezzouscita>0 then
    sell at prezzouscita stop
    endif
    endif
    if shortonmarket then
    if prezzouscita>0 then
    exitshort at prezzouscita stop
    endif
    endif
    endif
    
    set stop %loss 1.7
    Francesco, GraHal, Matriciel and 4 others thanked this post
    EURCAD-DhighDlow-v2.itf resultv2.png resultv2.png eqcurvev2.png eqcurvev2.png
    #120512 quote
    Francesco
    Participant
    Veteran

    200k is not the best.
    But it’s a very good starting point, needs to be watched better. Good job!

    popof356 thanked this post
    #120525 quote
    GraHal
    Participant
    Master

    Weird … I don’t get the same curve or stats as you and there is no Time that I need to align with UK time, so I can’t think why we should be different.

    I’m on SB and you are on CFD but I would expect that to only show a minor difference in performance stats?

    Any thoughts anyone or what do you get??

    I’ll try it on my CFD Platform.

    EDIT / PS

    Yep …. on CFD same as you now @swedshare … see 3rd image … how unsettling is that??

    Can only be that IG are playing around with the SB data to our disadvantage??

    Price and spread (2.5) are the same currently on SB and CFD, but they can’t always be else performance stats would be same on SB as CFD … or has my coffee not worked through yet?? 🙂

    Swede.jpg Swede.jpg Swede-2.jpg Swede-2.jpg
    #120532 quote
    GraHal
    Participant
    Master

    3rd image attached (missed off from above post).

    I get 74 trades on CFD (same as you) but I only get 58 trades on SB … and both charts are running over the same time period of 100k bars.

    Very worrying anomaly for us British .. is Brexit hurting us already!!?? 🙂 🙂

    Swede-3.jpg Swede-3.jpg
    #121630 quote
    Alfred
    Participant
    Average

    Thanks Swedshare! Its awesome!

    I am the beginninger in this.

    May I know the time 000000 to 200000, if my time zone is GMT+8.  The code any update? thanks.

    #125473 quote
    swedshare
    Participant
    Senior

    Alfred, you don’t really need to care about the time. It can run 24/7. The important part to notice is the relatively high risk. When/if a trade reaches its stoploss you will get a big loss.

    Another factor to consider is why the strategy only seems to work well on EUR/CAD and not the other currency pairs. That should rise a red flag 🙂

    Alfred thanked this post
    #125480 quote
    bertrandpinoy
    Participant
    Veteran

    Hello to you all,
    I have a good feedback on the EUR code USD H1. May I am still blocking about partial fences, impossible to run  in prorder. Can one of you help me?

    #125486 quote
    GraHal
    Participant
    Master

    May I am still blocking about partial fences

    Above does not make sense.

    But if you mean partial closures?  ProOrder does not allow partial closures.

    Change Sell and Exitshort to below

    Sell at Market
    ExitShort at Market
    bertrandpinoy thanked this post
    #125523 quote
    Alfred
    Participant
    Average

    Thanks Swedshare

    I have run this strategy one month ago, the result is ok

    #125713 quote
    bertrandpinoy
    Participant
    Veteran

    Hello Grahall, thank you for your reply. Indeed my first message was incorrectly translated by my English translation software. But you get it.
    Despite your trick, I can’t get the code to work.
    If I send it to you,  can you make the changes? I am a poor coder yet… To read you, thank you, cordially.

    #126351 quote
    fastsky
    Participant
    New

    Hi all, I backtested the EurUsd 15min and the EurCad 15min v2 and… 97% win. I actually tried to activate autotrading on my demo account of both with max 1 contract (100.000) and I’ll see. I just had to “//” the graph function on EurUSd otherwise the system won’t let me use it.

    Is there some parameter for auto trading you suggest me to set up?

    Thanks a lot

    #126352 quote
    MAKSIDE
    Participant
    Veteran

    @swedshare

    Are you sure about your strategy ?

    if tp not reached, > sl.  200k test/spread 2.5

    Capture9.png Capture9.png
    #126386 quote
    swedshare
    Participant
    Senior

    Hi @MAKSIDE

    I definately have doubts about the long term robustness of the strategy. I made some minor changes since the v2. See attached for current version. I have disabled the re-invest and only buy 1 contract each time. Also don’t hold position over weekend.  If you would like to check how the equity curve developes in 200k it would be appreciated. Spread is now set to 6 to reflect what IG offers. Initial capital 1000 CAD.

    // Created by Matriciel. Added MM, riskM and calender by swedshare
    // EURCAD Dhigh/Dlow v3 15m
    // spread = 6 (actual spread on IG CFD)
    
    defparam cumulateorders = false
    defparam preloadbars = 5000
    
    //code re-invest
    Capital = 1000 // initial capital
    Equity = Capital + StrategyProfit
    Position = Max(1, Equity * (1/Capital))
    Position = Round(Position*100)
    Position = Position/100 // not activated. Change "1" to "position" in the buy conditions to use re-invest.
    //********************
    
    set stop %loss 1.30
    
    //code quit strategy
    maxequity = max(equity,maxequity)
    DrawdownNeededToQuit = 40   // percent drawdown from max equity to stop strategy
    if equity < maxequity * (1 - (DrawdownNeededToQuit/100)) then
    quit
    endif
    //*****************
    
    // Force close of positions at Friday 21:30:00 (UTC+2 Europe/Berlin)
    if dayofweek = 5 and time = 213000 then
    IF longonmarket THEN
    SELL AT MARKET
    endif
    if shortonmarket then
    EXITSHORT AT MARKET
    ENDIF
    ENDIF
    //*************
    
    // Don't take position after friday 20:00:00 (UTC+2 Europe/Berlin)
    BadTime      = dayofweek = 5 AND OpenTime > 200000
    
    //*************
    
    once enablets = 1
    
    once select=1  // optimized for period1,2,3
    once tds   =1  // added on optimized results
    
    if select=1 then    // TF 15 MIN
    tr1=45
    tr2=25
    period1=78
    period2=12
    period3=4
    elsif select=2 then // TF 15 MIN
    tr1=45
    tr2=20
    period1=84
    period2=6
    period3=8
    endif
    
    // trend detection
    if tds=0 then
    trendup=1
    trenddown=1
    else
    if tds=1 then
    trendup=(Average[tr1](close)>Average[tr1](close)[1])
    trenddown=(Average[tr2](close)<Average[tr2](close)[1])
    else
    if tds=2 then
    endif
    endif
    endif
    
    mm = average[period1,3](totalprice)
    
    Newhighest=max(DHigh(0), DHigh(1))
    Newlowest=min(DLow(0), DLow(1))
    
    avghl = (Newhighest+Newlowest)/2
    
    c1 = average[period2,period3]((Newhighest+avghl)/2)
    c2 = average[period2,period3]((Newlowest+avghl)/2)
    
    condbuy = mm > c1
    condbuy = condbuy and close crosses over avghl
    condbuy = condbuy and trendup
    
    condsell = mm < c2
    condsell = condsell and close crosses under avghl
    condsell = condsell and trenddown
    
    if condbuy and not BadTime then
    buy 1 contract at market
    endif
    if condsell and not BadTime then
    sellshort 1 contract at market
    endif
    //endif
    
    // trailing stop atr
    if enablets then
    //
    once steps=0                   // set to 0 to ignore steps
    once minatrdist=16
    
    once atrtrailingperiod    = 14 // atr parameter value
    once minstop              = 0  // minimum trailing stop distance
    
    if barindex=tradeindex then
    trailingstoplong     = 16   // trailing stop atr relative distance
    trailingstopshort    = 16   // trailing stop atr relative distance
    else
    if longonmarket then
    if prezzouscita>0 then
    if trailingstoplong>minatrdist then
    if prezzouscita>prezzouscita[1] then
    trailingstoplong=trailingstoplong
    else
    trailingstoplong=trailingstoplong-steps
    endif
    else
    trailingstoplong=minatrdist
    endif
    endif
    endif
    
    if shortonmarket then
    if prezzouscita>0 then
    if trailingstopshort>minatrdist then
    if prezzouscita<prezzouscita[1] then
    trailingstopshort=trailingstopshort
    else
    trailingstopshort=trailingstopshort-steps
    endif
    else
    trailingstopshort=minatrdist
    endif
    endif
    endif
    endif
    //
    atrtrail=averagetruerange[atrtrailingperiod]((close/1)*pipsize)
    trailingstartl=round(atrtrail*trailingstoplong)
    trailingstarts=round(atrtrail*trailingstopshort)
    tgl=trailingstartl
    tgs=trailingstarts
    if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
    maxprice=0
    minprice=close
    prezzouscita=0
    endif
    //
    if longonmarket then
    maxprice=max(maxprice,close)
    if maxprice-tradeprice(1)>=tgl*pointsize then
    if maxprice-tradeprice(1)>=minstop then
    prezzouscita=maxprice-tgl*pointsize
    else
    prezzouscita=maxprice-minstop*pointsize
    endif
    endif
    endif
    //
    if shortonmarket then
    minprice=min(minprice,close)
    if tradeprice(1)-minprice>=tgs*pointsize then
    if tradeprice(1)-minprice>=minstop then
    prezzouscita=minprice+tgs*pointsize
    else
    prezzouscita=minprice+minstop*pointsize
    endif
    endif
    endif
    //
    if longonmarket then
    if prezzouscita>0 then
    sell at prezzouscita stop
    endif
    endif
    if shortonmarket then
    if prezzouscita>0 then
    exitshort at prezzouscita stop
    endif
    endif
    endif
    
    bertrandpinoy thanked this post
    EURCAD-DhighDlow-15m-v3.itf ecurve.jpg ecurve.jpg report.jpg report.jpg
Viewing 15 posts - 76 through 90 (of 119 total)
  • You must be logged in to reply to this topic.

Discussing Matriciel EURUSD Dhigh Dlow


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
BobFlynn @bobflynn Participant
Summary

This topic contains 118 replies,
has 33 voices, and was last updated by nonetheless
5 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/05/2019
Status: Active
Attachments: 55 files
Logo Logo
Loading...