Discussing Matriciel EURUSD Dhigh Dlow

Viewing 15 posts - 1 through 15 (of 119 total)
  • Author
    Posts
  • #114248 quote
    BobFlynnBobFlynn
    Participant
    Senior

    Hello community,

    I open this topic to discuss and improve together Matriciel’s EURUSD HighLow strategy : https://www.prorealcode.com/prorealtime-trading-strategies/eurusd-15-minutes-timeframe-dhigh-dlow-strategy/

    I think it has a great potential, and apparently we are struggling to communicate updates to each other through the comments.

    #114251 quote
    MatricielMatriciel
    Participant
    Master

    This is the code :

    DEFPARAM CumulateOrders = True
    DEFPARAM PRELOADBARS = 10000
    
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    Horaire = time >= 000000 and time <= 200000
    
    CloturePartielle = 1// 1 = ON, 0 = OFF
    PositionsizeA = 1
    PositionsizeV = 1
    MAXSHARES = abs(COUNTOFPOSITION) <= 19
    
    IF CloturePartielle THEN
    PositionsizeA = 4
    PositionsizeV = 3
    ENDIF
    
    MM = Average[56,3](totalprice)
    
    Newhighest = max(DHigh(0),DHigh(1))
    Newlowest = min(DLow(0),DLow(1))
    
    Milieu = (Newhighest+Newlowest)/2
    Surachat = average[10,4]((Newhighest+Milieu)/2)
    Survente = average[10,4]((Newlowest+Milieu)/2)
    
    CA = (MM > Surachat) and (close crosses over Milieu)
    CV = (MM < Survente) and (close crosses under Milieu)
    
    // Long Entries
    IF Horaire AND CA AND MAXSHARES AND not daysForbiddenEntry AND NOT SHORTONMARKET THEN
    BUY PositionsizeA CONTRACTS AT MARKET
    ENDIF
    
    IF CloturePartielle THEN
    IF LONGONMARKET AND COUNTOFLONGSHARES <= 16 THEN
    SELL 1 CONTRACTS AT TRADEPRICE + 40*pointsize LIMIT
    ENDIF
    
    IF LONGONMARKET AND COUNTOFLONGSHARES <= 4 THEN
    SELL 1 CONTRACTS AT TRADEPRICE + 20*pointsize LIMIT
    ENDIF
    
    IF LONGONMARKET AND COUNTOFLONGSHARES <= 6 THEN
    SELL 1 CONTRACTS AT TRADEPRICE + 18*pointsize LIMIT
    ENDIF
    ENDIF
    
    IF LONGONMARKET AND summation[35](close < close[6]) = 35 THEN
    SELL AT MARKET
    ENDIF
    
    // Short Entries
    IF Horaire AND CV AND MAXSHARES AND not daysForbiddenEntry AND NOT LONGONMARKET THEN
    SELLSHORT PositionsizeV CONTRACTS AT MARKET
    ENDIF
    
    IF CloturePartielle THEN
    IF SHORTONMARKET AND COUNTOFSHORTSHARES <= 20 THEN
    EXITSHORT 1 CONTRACTS AT TRADEPRICE - 78*pointsize LIMIT
    ENDIF
    
    IF SHORTONMARKET AND COUNTOFLONGSHARES <= 1 THEN
    EXITSHORT 1 CONTRACTS AT TRADEPRICE - 40*pointsize LIMIT
    ENDIF
    ENDIF
    
    IF SHORTONMARKET AND summation[32](close > close[6]) = 32 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    //MFE
    //trailing stop
    trailingstop = 33
     
    //resetting variables when no trades are on market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif
     
    //case SHORT order
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    endif
     
    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
    endif
    endif
     
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif
    
    //SET TARGET pPROFIT 46
    SET STOP pLOSS 200
    #114253 quote
    GraHalGraHal
    Participant
    Master

    Don’t you just hate it when Nicolas does a refresh of the website between starting to write a message and posting it and then we end up not logged in and so the post is lost / not posted!?

    Fortunately is was not a long post so I’ll do it again later.

    Apologies for the moan @Nicolas , I know you have to do maintenance 🙂

    I think I may copy posts to clipboard in future before posting?

    This ‘moaning post’ is longer than the post I lost so I’d have been better keeping my mouth shut and re doing my original post!  🙂

    #114254 quote
    BobFlynnBobFlynn
    Participant
    Senior

    This ‘moaning post’ is longer than the post I lost so I’d have been better keeping my mouth shut and re doing my original post! 🙂

    We want the original post now ! 😛

    #114255 quote
    GraHalGraHal
    Participant
    Master

    I’ve had 2 trades only since 17 Oct 19 on Forward Test of this  System … both in profit!

    I didn’t Accumulate Orders (position size = 1) so only £58 profit, but 2 out of 2 in profit is a good start.

    For whatever the reason, I am testing it on 10 min TF (eurusd)

    Will Lines 41, 45, 61 and 64 (ish) work in real as they are partial exits?

    I used, for example …

    SELL AT TRADEPRICE + 20*pointsize LIMIT
    #114256 quote
    NicolasNicolas
    Keymaster
    Legend

    Don’t you just hate it when Nicolas does a refresh of the website between starting to write a message and posting it and then we end up not logged in and so the post is lost / not posted!?

    That wasn’t me, it happens sometimes automatically for security of your account, but not often!

    GraHal thanked this post
    #114287 quote
    darbesdarbes
    Participant
    Average

    Code works in backtest but how to overcome the partial close issue ?

    #114289 quote
    VonasiVonasi
    Moderator
    Master

    how to overcome the partial close issue ?

    Partial closure is only possible in back testing – not in live demo or live real trading unfortunately. There is no way round this except to ask IG when they plan to let us all partially close positions.

    #114290 quote
    GraHalGraHal
    Participant
    Master

    how to overcome the partial close issue ?

    You mean you want to do partial closures or you want to eliminate partial closures?

    If you want to eliminate then use …

    SELL AT TRADEPRICE + 20*pointsize LIMIT
    
    ExitShort AT TRADEPRICE + 20*pointsize LIMIT
    #114303 quote
    NicolasNicolas
    Keymaster
    Legend

    @investment_account (GraHal)

    Did you get my email yesterday?

    GraHal thanked this post
    #114370 quote
    darbesdarbes
    Participant
    Average

    Tku. I will try strategy without partial close.

    #114421 quote
    J.J.
    Participant
    Average

    I modified the code a little bit to add a compounding effect. In back testing I noticed it started of with a loss the first 6 months, if you calculate position size based on your current capital, it will make for better risk management in my opinion. I took $10k as starting capital for this example.

    Below my code.

    DEFPARAM CumulateOrders = True
    DEFPARAM PRELOADBARS = 10000
    
    //calculate position size based on capital
    AMOUNT = (10000 + STRATEGYPROFIT) * 0.0001
     
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
     
    Horaire = time >= 000000 and time <= 200000
     
    CloturePartielle = 1// 1 = ON, 0 = OFF
    PositionsizeA = 1 * AMOUNT
    PositionsizeV = 1 * AMOUNT
    MAXSHARES = abs(COUNTOFPOSITION) <= 19 * AMOUNT
     
    IF CloturePartielle THEN
    PositionsizeA = 4 * AMOUNT
    PositionsizeV = 3 * AMOUNT
    ENDIF
     
    MM = Average[56,3](totalprice)
     
    Newhighest = max(DHigh(0),DHigh(1))
    Newlowest = min(DLow(0),DLow(1))
     
    Milieu = (Newhighest+Newlowest)/2
    Surachat = average[10,4]((Newhighest+Milieu)/2)
    Survente = average[10,4]((Newlowest+Milieu)/2)
     
    CA = (MM > Surachat) and (close crosses over Milieu)
    CV = (MM < Survente) and (close crosses under Milieu)
     
    // Long Entries
    IF Horaire AND CA AND MAXSHARES AND not daysForbiddenEntry AND NOT SHORTONMARKET THEN
    BUY PositionsizeA CONTRACTS AT MARKET
    ENDIF
     
    IF CloturePartielle THEN
    IF LONGONMARKET AND COUNTOFLONGSHARES <= 16 THEN
    SELL 1 CONTRACTS AT TRADEPRICE + 40*pointsize LIMIT
    ENDIF
     
    IF LONGONMARKET AND COUNTOFLONGSHARES <= 4 THEN
    SELL 1 CONTRACTS AT TRADEPRICE + 20*pointsize LIMIT
    ENDIF
     
    IF LONGONMARKET AND COUNTOFLONGSHARES <= 6 THEN
    SELL 1 CONTRACTS AT TRADEPRICE + 18*pointsize LIMIT
    ENDIF
    ENDIF
     
    IF LONGONMARKET AND summation[35](close < close[6]) = 35 THEN
    SELL AT MARKET
    ENDIF
     
    // Short Entries
    IF Horaire AND CV AND MAXSHARES AND not daysForbiddenEntry AND NOT LONGONMARKET THEN
    SELLSHORT PositionsizeV CONTRACTS AT MARKET
    ENDIF
     
    IF CloturePartielle THEN
    IF SHORTONMARKET AND COUNTOFSHORTSHARES <= 20 THEN
    EXITSHORT 1 CONTRACTS AT TRADEPRICE - 78*pointsize LIMIT
    ENDIF
     
    IF SHORTONMARKET AND COUNTOFLONGSHARES <= 1 THEN
    EXITSHORT 1 CONTRACTS AT TRADEPRICE - 40*pointsize LIMIT
    ENDIF
    ENDIF
     
    IF SHORTONMARKET AND summation[32](close > close[6]) = 32 THEN
    EXITSHORT AT MARKET
    ENDIF
     
    //MFE
    //trailing stop
    trailingstop = 33
     
    //resetting variables when no trades are on market
    if not onmarket then
    MAXPRICE = 0
    MINPRICE = close
    priceexit = 0
    endif
     
    //case SHORT order
    if shortonmarket then
    MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
    if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
    endif
    endif
     
    //case LONG order
    if longonmarket then
    MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
    if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
    priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
    endif
    endif
     
    //exit on trailing stop price levels
    if onmarket and priceexit>0 then
    EXITSHORT AT priceexit STOP
    SELL AT priceexit STOP
    endif
     
    //SET TARGET pPROFIT 46
    SET STOP pLOSS 200
    
    GraHal and quietlife thanked this post
    #114453 quote
    GraHalGraHal
    Participant
    Master

    Do you get the results attached @J. Slowly?

    I deducted 1 hour from your times (UTC +1) to get UTC +00 (UK time) and I used spread = 2.

    Slowly.jpg Slowly.jpg Slowly-2.jpg Slowly-2.jpg
    #114744 quote
    juju333juju333
    Participant
    Average

    Thanks for sharing. Works great in test indeed, ever greater with EURCAD isn’t it ? Does somenone has the code without partial closure wich indeed prevent form pushing it towards ProOrder ? Don’t have yet the time to clean it. Without partial closure, are the results still good ? Thanks !

    #114815 quote
    GubbenGubben
    Participant
    Senior

    Results are good but drawdown is huge

Viewing 15 posts - 1 through 15 (of 119 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

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 nonethelessnonetheless
5 years, 7 months ago.

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