Discussing the strategy VECTORIAL DAX (M5)

Viewing 15 posts - 811 through 825 (of 1,264 total)
  • Author
    Posts
  • #142858 quote
    nonetheless
    Participant
    Master

    where in the code does it calculate the ‘positionsize’ for which PositionSizeLong and PositionSizeShort are derived?

    At line 7 you can have positionsize = any value you like. With MM= 0 it won’t change.

    // VECTORIAL MM - DJ 3m
    DEFPARAM CumulateOrders = false
    DEFPARAM Preloadbars = 50000
    //Money Management
    MM = 0 // = 0 for optimization
    if MM = 0 then
    positionsize=.5

    I have been running a 5m long version of this over the past couple of months. It’s basically a merger between Vectorial and MoD, so far fairly consistent with the back test.

    DEFPARAM CumulateOrders = false
    DEFPARAM Preloadbars = 50000
    //Money Management
    MM = 1 // = 0 for optimization
    if MM = 0 then
    positionsize=.5
    ENDIF
    if MM = 1 then
    ONCE startpositionsize = .5
    ONCE factor = 10 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etc
    ONCE margin = (close*.005) // tier 1 margin value of 1 contract in instrument currency; change decimal according to available leverage
    ONCE margin2 = (close*.01)// tier 2 margin value of 1 contract in instrument currency; change decimal according to available leverage
    ONCE tier1 = 55 // IG first tier margin limit
    ONCE maxpositionsize = 550 //  IG tier 2 margin limit
    ONCE minpositionsize = .2 // enter minimum position allowed
    IF Not OnMarket THEN
    positionsize = startpositionsize + Strategyprofit/(factor*margin)
    ENDIF
    IF Not OnMarket THEN
    IF startpositionsize + Strategyprofit/(factor*margin) > tier1 then
    positionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor*margin2)) + tier1 //incorporating tier 2 margin
    ENDIF
    IF Not OnMarket THEN
    if startpositionsize + Strategyprofit/(factor*margin) < minpositionsize THEN
    positionsize = minpositionsize //keeps positionsize from going below allowed minimum
    ENDIF
    IF (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor*margin2)) + tier1 > maxpositionsize then
    positionsize = maxpositionsize// keeps positionsize from going above IG tier 2 margin limit
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    
    Ctime = time >= 010000 and time <= 230000
    
    TIMEFRAME(2 hours)
    Period= 240
    inner = 2*weightedaverage[round( Period/2)](typicalprice)-weightedaverage[Period](typicalprice)
    HULLa = weightedaverage[round(sqrt(Period))](inner)
    c9 = HULLa > HULLa[1]
    //c2 = HULLa < HULLa[1]
    
    TIMEFRAME(15 minutes)
    mx1 = average[16,1](close)
    c7 = mx1 > mx1[1]
    //c8 = mx1 < mx1[1]
    
    TIMEFRAME(10 minutes)
    mx2 = average[15,0](close)
    c5 = mx2 > mx2[1]
    //c6 = mx2 < mx2[1]
    
    //Stochastic RSI | indicator
    lengthRSI = 10//RSI period
    lengthStoch = 16//Stochastic period
    smoothK = 16 //Smooth signal of stochastic RSI
    smoothD = 3 //Smooth signal of smoothed stochastic RSI
    myRSI = RSI[lengthRSI](close)
    MinRSI = lowest[lengthStoch](myrsi)
    MaxRSI = highest[lengthStoch](myrsi)
    StochRSI = (myRSI-MinRSI) / (MaxRSI-MinRSI)
    K = average[smoothK](stochrsi)*100
    D = average[smoothD](K)
    c3 = K>D
    //c4 = K<D
    
    TIMEFRAME(default)
    indicator4 = SuperTrend[1,7]
    c1 = (close > indicator4)
    //c2 = (close < indicator4)
    
    //VECTEUR = CALCUL DE L'ANGLE
    ONCE PeriodeA = 5
    ONCE nbChandelierA= 42
    MMA = Exponentialaverage[PeriodeA](close)
    ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierA
    ANGLE = (ATAN(ADJASUROPPO)) //FONCTION ARC TANGENTE
    CondBuy1 = ANGLE >= 31
    //CondSell1 = ANGLE <= - 25
    
    
    //VECTEUR = CALCUL DE LA PENTE ET SA MOYENNE MOBILE
    ONCE PeriodeB = 24
    ONCE nbChandelierB= 50
    lag = 4
    MMB = Exponentialaverage[PeriodeB](close)
    pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierB
    trigger = Exponentialaverage[PeriodeB+lag](pente)
    CondBuy2 = (pente > trigger) AND (pente < 0)
    //CondSell2 = (pente CROSSES UNDER trigger) AND (pente > -1)
    
    
    
    //ENTREES EN POSITION
    CONDBUY = CondBuy1 and CondBuy2 and Ctime and c1 and c3 and c5 and c7 and c9
    //CONDSELL = CondSell1 and CondSell2 and Ctime and c2 and c4 and c6 and c8
    
    
    //POSITION LONGUE
    IF CONDBUY THEN
    buy positionsize contract at market
    SET STOP %LOSS 1.7
    SET TARGET %PROFIT 2.1
    ENDIF
    
    //POSITION COURTE
    //IF CONDSELL THEN
    //Sellshort positionsize contract at market
    //SET STOP %LOSS sls
    //SET TARGET %PROFIT tps
    //ENDIF
    
    //Break even
    once breakeven = 1//1 on - 0 off
    
    breakevenPercent = .22
    PointsToKeep = 2
    startBreakeven = tradeprice(1)*(breakevenpercent/100)
    
    //reset the breakevenLevel when no trade are on market
    if breakeven>0 then
    IF NOT ONMARKET THEN
    breakevenLevel=0
    ENDIF
    // --- BUY SIDE ---
    //test if the price have moved favourably of "startBreakeven" points already
    IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN
    //calculate the breakevenLevel
    breakevenLevel = tradeprice(1)+PointsToKeep*pipsize
    ENDIF
     
    //place the new stop orders on market at breakevenLevel
    IF breakevenLevel>0 THEN
    SELL AT breakevenLevel STOP
    ENDIF
    // --- end of BUY SIDE ---
     
    IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN
    //calculate the breakevenLevel
    breakevenLevel = tradeprice(1)-PointsToKeep*pipsize
    ENDIF
    //place the new stop orders on market at breakevenLevel
    IF breakevenLevel>0 THEN
    EXITSHORT AT breakevenLevel STOP
    ENDIF
    endif
    
    //****************************************************************************************
    // trailing atr stop II
    once trailingstoptype     = 1    // trailing stop - 0 off, 1 on
    
    once tsincrements = 0         // set to 0 to ignore tsincrements
    once tsminatrdist = 2
    
    once tsatrperiod    = 14         // ts atr parameter
    once tsminstop      = 12         // ts minimum stop distance
    
    once tssensitivity        = 0    // [0]close;[1]high/low
    
    if trailingstoptype then
    if barindex=tradeindex then
    trailingstoplong     = 9   // ts atr distance
    trailingstopshort    = 9  // ts atr distance
    else
    if longonmarket then
    if tsnewsl>0 then
    if trailingstoplong>tsminatrdist then
    if tsnewsl>tsnewsl[1] then
    trailingstoplong=trailingstoplong
    else
    trailingstoplong=trailingstoplong-tsincrements
    endif
    else
    trailingstoplong=tsminatrdist
    endif
    endif
    endif
    if shortonmarket then
    if tsnewsl>0 then
    if trailingstopshort>tsminatrdist then
    if tsnewsl<tsnewsl[1] then
    trailingstopshort=trailingstopshort
    else
    trailingstopshort=trailingstopshort-tsincrements
    endif
    else
    trailingstopshort=tsminatrdist
    endif
    endif
    endif
    endif
    
    tsatr=averagetruerange[tsatrperiod]((close/10)*pipsize)/1000
    //tsatr=averagetruerange[tsatrperiod]((close/1)*pipsize) // (forex)
    tgl=round(tsatr*trailingstoplong)
    tgs=round(tsatr*trailingstopshort)
    if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
    tsmaxprice=0
    tsminprice=close
    tsnewsl=0
    endif
    if tssensitivity then
    tssensitivitylong=high
    tssensitivityshort=low
    else
    tssensitivitylong=close
    tssensitivityshort=close
    endif
    if longonmarket then
    tsmaxprice=max(tsmaxprice,tssensitivitylong)
    if tsmaxprice-tradeprice(1)>=tgl*pointsize then
    if tsmaxprice-tradeprice(1)>=tsminstop then
    tsnewsl=tsmaxprice-tgl*pointsize
    else
    tsnewsl=tsmaxprice-tsminstop*pointsize
    endif
    endif
    endif
    if shortonmarket then
    tsminprice=min(tsminprice,tssensitivityshort)
    if tradeprice(1)-tsminprice>=tgs*pointsize then
    if tradeprice(1)-tsminprice>=tsminstop then
    tsnewsl=tsminprice+tgs*pointsize
    else
    tsnewsl=tsminprice+tsminstop*pointsize
    endif
    endif
    endif
    if longonmarket then
    if tsnewsl>0 then
    sell at tsnewsl stop
    endif
    if tsnewsl>0 then
    if low crosses under tsnewsl then
    sell at market // when stop is rejected
    endif
    endif
    endif
    if shortonmarket then
    if tsnewsl>0 then
    exitshort at tsnewsl stop
    endif
    if tsnewsl>0 then
    if high crosses over tsnewsl then
    exitshort at market // when stop is rejected
    endif
    endif
    endif
    Francesco, Balmora74 and boonet thanked this post
    DJ-5m-Vectorial-V3-L-forward-test.jpg DJ-5m-Vectorial-V3-L-forward-test.jpg
    #142863 quote
    Francesco
    Participant
    Veteran

    Welcome back nonetheless 🙂

    nonetheless thanked this post
    #142866 quote
    Artemois
    Participant
    Average

    @nonetheless

    Welcome back 🙂

    I put Your last code above in PRT but my backtest is different from Yours. I also needed to add an “endif” in the end. I’m running version 10.3
    Have I done something wrong?

    DJ-5M-Vectorial-3L-20-08-28.itf
    #142868 quote
    deletedaccount051022
    Participant
    New

    Hello nonetheless

    Hope you are well.  Many thanks for your reply.  I just tried your suggestion with the code you posted above and it worked.  I will try to incorporate this back into the version of the Vectorial code I had downloaded preciously.

    Thanks

    S

    #142869 quote
    nonetheless
    Participant
    Master

    my backtest is different from Yours

    hi Artemois, live forward tests will always vary from the back test for multiple reasons. Also, I think mine was stopped and restarted some time in August so the MM will have reset. But when I run a back test for those 2 months, I see v similar performance ~91%

    and yes, it does need another endif – got lost in the copy/paste

    #142870 quote
    nonetheless
    Participant
    Master

    Also, please note that i didnt do any WF or VRT for this; the straight back test looked good and I was curious about the basic concept so I put it on demo for a couple of months, that’s all. I’m sure it can be improved

    #142873 quote
    Artemois
    Participant
    Average

    Hi Nonetheless

    My bad, I didn’t understand it was Your actual result but thought it was the backtest 😉

    Below is a backtest for the same dates.

    Backtest-2020-06-26-2020-08-28.jpg Backtest-2020-06-26-2020-08-28.jpg
    #142883 quote
    GraHal
    Participant
    Master

    I got same backtest result as Artemois … different / reduced  by a factor of 15 ish from Nonetheless Pro-Order results.

    Big difference … something must be wrong?

    #142890 quote
    GraHal
    Participant
    Master

    This is well weird … I ran Nonetheless code above again 2 mins ago and got completely different results than I was getting last night!

    Nearer / more comparable with None’s now … see attached.  I still get far more drawdown though … mine dd at £947 vs None’s dd at £64

    What do you get this morning @Artemois ??

    None.jpg None.jpg None-2.jpg None-2.jpg
    #142896 quote
    GraHal
    Participant
    Master

    I’m putting attached on Forward Test on Monday … MM turned off and Period = 55 at Line 37.

    Above is all I explored, I’m sure there would be other beneficial changes?

    It be great if we had a Short version or Long and Short in same System?

    Thank You for sharing Nonetheless!

    None-3.jpg None-3.jpg None-4.jpg None-4.jpg
    #142907 quote
    Artemois
    Participant
    Average

    Hi Grahal

    I get the same results today as yesterday

    I made a backtest on the DJ 3m Vectorial V3 for the same period and it has been more succesfull.
    I also made one of  200 kpts

    I find them both interesting!

    Thank You  @Nonetheless  for sharing, it is very interesting as a beginner to se what the more experienced people are doing.

    Backtest-DJ-3m-Vectorial-V3-2020-06-26-2020-08-28.jpg Backtest-DJ-3m-Vectorial-V3-2020-06-26-2020-08-28.jpg Backtest-DJ-3m-Vectorial-V3-2019-07-17-2020-08-28.jpg Backtest-DJ-3m-Vectorial-V3-2019-07-17-2020-08-28.jpg
    #142921 quote
    nonetheless
    Participant
    Master

    Hi Grahal, how’s it going?

    No idea why you got such varying results from this. I have attached the itf, just in case something got corrupted in the copy/paste. Also the 200k back tests for long and short, with a comparison look at the 3m v3. Obviously the latter is only 13 months, as opposed to 32.

    I also found some tests that I did back in the spring of the 5m long version … seems to check out. But as I said, I really did this out of curiosity to try marrying Balmora’s Vectorial with MoD … and then I kinda forgot about it.

    GraHal thanked this post
    DJ-5m-Vectorial-V3-L-WF-VRT.jpg DJ-5m-Vectorial-V3-L-WF-VRT.jpg
    #142923 quote
    nonetheless
    Participant
    Master
    #142932 quote
    Artemois
    Participant
    Average

    Both the Vectorial and the MOD are very interesting codes. MOD has a slightly bigger problem with DD but apart from that it has potential. This, and especially the 3 min version is good.
    Is there a chance of any further development ?

    #143034 quote
    antonio73
    Participant
    Junior

    Ciao Balmora74 vedo che il tuo sistema anche su timeframe ad 1 minuto funziona bene ottimizzato, tu cosa ne pensi?

    Hi Balmora74 I see that your system even on 1 minute timeframe works well optimized, what do you think?

Viewing 15 posts - 811 through 825 (of 1,264 total)
  • You must be logged in to reply to this topic.

Discussing the strategy VECTORIAL DAX (M5)


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Balmora74 @balmora74 Participant
Summary

This topic contains 1,263 replies,
has 125 voices, and was last updated by VinzentVega
1 year ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/24/2019
Status: Active
Attachments: 470 files
Logo Logo
Loading...