System stopped [defparam] by this code

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #144579 quote
    Alfred
    Participant
    Average

    Hi

    Who can explain the meaning the following code? because I had run some, but sometimes was stopped by systems.  It said I need to amend this.  Many thanks.

    defparam cumulateorders = true / false ???
    defparam preloadbars    = 10000
    #144582 quote
    GraHal
    Participant
    Master

    Try below …

    defparam cumulateorders = True //or False, but not both :)
    #144610 quote
    Alfred
    Participant
    Average

    Thanks GraHal

    I tried it “True” and “False”,  system still reject it immediately.

    Stopped-notice.png Stopped-notice.png
    #144613 quote
    MAKSIDE
    Participant
    Veteran

    It’s also a problem with preloadbars instruction. Try to increase the number.. There is a problem with history data of an indicator inside

    #144633 quote
    GraHal
    Participant
    Master

    I tried it “True” and “False”,  system still reject it immediately.

    What happens if you delete defparam cumulateorders altogether?

    If Algo still gets rejected then something else is causing Rejection?

    #144634 quote
    GraHal
    Participant
    Master

    Try  testing on a reduced number of bars until the Algo does not get Rejected.

    Let us know how you get on please?

    #144736 quote
    Alfred
    Participant
    Average

    I have deleted the “defparam cumulateorders”, ran 3 hours, then also was stopped.  🙁

    This system has also run in other instruments, no this issue.

    p.s., I am using Vectorial, and Mother of Dragon also have this problem.

    #144743 quote
    robertogozzi
    Moderator
    Master

    You should post the code and tell us the instrument you are trading, in order to try to replicate the issue.

    #144750 quote
    GraHal
    Participant
    Master

    ran 3 hours

    Try it on 3 hour timeframe and on 100 bars and let us know how you get on?

    #144753 quote
    Alfred
    Participant
    Average
    defparam cumulateorders = true
    defparam preloadbars    = 10000
    
    once tradetype         = 1 // [1]long/short [2]long [3]short
    once reenter           = 1 // [1]on [0]off (off ignores positionperftype/value below)
    once positionperftype  = 0 // [0]loss/gain [1]loss [2]gain
    once positionperfvalue = 0.1 // % (0 or higher)
    
    once stochasticrsi = 1
    
    once sll = 1.6  // stoploss long
    once sls = 1.8  // stoploss short
    
    once ptl = undefined  // profit target long
    once pts = undefined  // profit target short
    
    once overnightposition  = 1
    once weekendposition    = 1
    
    // money management
    MM = 0 // = 0 for optimization
    if MM = 0 then
    positionsize=1 //
    ENDIF
    
    if MM = 1 then
    
    ENDIF
    ENDIF
    
    if overnightposition=1 and weekendposition=1 then
    ctime = (time>=14000 and time=<240000 or time>=000000 and time<3500) and not (time>=120000 and time<130000 or time>=50000 and time<60000)
    elsif overnightposition=0 then
    ctime = (time>=044500 and time<220000) //and not (time>=153000 and time<163300)
    elsif overnightposition=1 and weekendposition=0 then
    ctime = ((dayofweek<5 and time>=044500 and time<230000) or (dayofweek=5 and time>=044500 and time<220000)) //and not (time>=153000 and time<163300)
    endif
    
    once periodea      = 33  //14
    once nbchandeliera = 14 //20
    once periodeb      = 32 //29
    once nbchandelierb = 48 //41
    
    mma = exponentialaverage[periodea](close)
    adjasuroppo = (mma-mma[nbchandeliera]*pipsize) / nbchandeliera
    angle = (atan(adjasuroppo))
    
    mmb = exponentialaverage[periodeb](close)
    pente = (mmb-mmb[nbchandelierb]*pipsize) / nbchandelierb
    trigger = exponentialaverage[periodeb](pente)
    
    cb1 = angle >= 34
    cs1 = angle <= -28
    
    cb2 = (pente crosses over  trigger) and (pente >-6 and pente < 1)
    cs2 = (pente crosses under trigger) and (pente >-11 and pente < 9)
    
    //entrees en position
    condbuy  = cb1 and cb2 //and low<>dlow(0) //and close<>low
    condsell = cs1 and cs2 //and high<>dhigh(0) //and close<>high
    
    //stochastic rsi | indicator
    if stochasticrsi then
    lengthrsi   = 11 // 2 rsi period
    lengthstoch = 2 // 6 stochastic period
    smoothk     = 4 // 4 smooth signal of stochastic rsi
    smoothd     = 10 // 8 smooth signal of smoothed stochastic rsi
    myrsi  = rsi[lengthrsi](totalprice)
    minrsi = lowest[lengthstoch](myrsi)
    maxrsi = highest[lengthstoch](myrsi)
    stochrsi = (myrsi-minrsi) / (maxrsi-minrsi)
    k = average[smoothk](stochrsi)*100
    d = average[smoothd](k)
    c13 = k>d
    c14 = k<d
    condbuy = condbuy  and c13
    condsell= condsell and c14
    else
    c13=c13
    c14=c14
    endif
    
    // entry criteria
    if ctime  then
    if (tradetype=1 or tradetype=2) then
    if condbuy and not longonmarket then
    buy positionsize contract at market
    if tradetype=1 then
    set stop %loss sll
    set target %profit ptl
    elsif tradetype=2 then
    set stop %loss sll
    set target %profit ptl
    endif
    endif
    endif
    if (tradetype=1 or tradetype=3) then
    if condsell and not shortonmarket then
    sellshort positionsize contract at market
    if tradetype=1 then
    set stop %loss sls
    set target %profit pts
    elsif tradetype=3 then
    set stop %loss sls
    set target %profit pts
    endif
    endif
    endif
    if reenter then
    if positionperftype=1 then
    positionperformance=positionperf(0)*100<-positionperfvalue
    elsif positionperftype=2 then
    positionperformance=positionperf(0)*100>positionperfvalue
    else
    positionperformance=((positionperf(0)*100)<-positionperfvalue or (positionperf(0)*100)>positionperfvalue)
    endif
    if (tradetype=1 or tradetype=2) then
    if condbuy and longonmarket and positionperformance then
    sell at market
    endif
    if condbuy[1] and not longonmarket then
    buy positionsize contract at market
    if tradetype=1 then
    set stop %loss sll
    set target %profit ptl
    elsif tradetype=2 then
    set stop %loss sll
    set target %profit ptl
    endif
    endif
    endif
    if (tradetype=1 or tradetype=3) then
    if condsell and shortonmarket and positionperformance then
    exitshort at market
    endif
    if condsell[1] and not shortonmarket then
    sellshort positionsize contract at market
    if tradetype=1 then
    set stop %loss sls
    set target %profit pts
    elsif tradetype=3 then
    set stop %loss sls
    set target %profit pts
    endif
    endif
    endif
    endif
    else
    if longonmarket and condsell then
    //sell at market
    endif
    if shortonmarket and condbuy then
    //exitshort at market
    endif
    endif
    
    // break even stop
    once enablebe = 1
    
    if enablebe then
    once besg = 0.89//0.25   //% break even stop gain
    once besl = -0.001//0.75  //% break even stop level (+ or -)
    if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
    benewsl=0
    endif
    if longonmarket then
    if high-tradeprice(1)>=((tradeprice(1)/100)*besg)*pointsize then
    benewsl=tradeprice(1)+((tradeprice(1)/100)*besl)*pointsize
    endif
    endif
    if shortonmarket then
    if tradeprice(1)-low>=((tradeprice(1)/100)*besg)*pointsize then
    benewsl=tradeprice(1)-((tradeprice(1)/100)*besl)*pointsize
    endif
    endif
    if barindex-tradeindex>1 then
    if longonmarket then
    if benewsl>0 then
    sell at benewsl stop
    endif
    if benewsl>0 then
    if low crosses under benewsl then
    sell at market
    endif
    endif
    endif
    if shortonmarket then
    if benewsl>0 then
    exitshort at benewsl stop
    endif
    if benewsl>0 then
    if high crosses over benewsl then
    exitshort at market
    endif
    endif
    endif
    endif
    endif
    
    // trailing atr stop
    once trailingstoptype1     = 1      // trailing stop - 0 off, 1 on
    
    if trailingstoptype1 then
    once tsincrements = 0.11         // set to 0 to ignore tsincrements
    once tsminatrdist = 1
    
    once tsatrperiod    = 9         // ts atr parameter
    once tsminstop      = 20         // ts minimum stop distance
    
    once tssensitivity        = 1    // [0]close;[1]high/low
    if barindex=tradeindex then
    trailingstoplong     = 10      // ts atr distance
    trailingstopshort    = 8      // 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 barindex-tradeindex>1 then
    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
    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
    endif
    endif
    endif
    endif
    endif
    
    // trailing stop percentage
    once trailingstoptype2=1
    
    if trailingstoptype2 then
    once trailingpercent = 1
    once steppercent     = (trailingpercent/10)*1
    if onmarket then
    trailingstart = tradeprice(1)*(trailingpercent/100)
    trailingstep = tradeprice(1)*(steppercent/100)
    endif
    if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
    newsl=0
    endif
    if longonmarket then
    if newsl=0 and high-tradeprice(1)>=trailingstart then
    newsl = tradeprice(1)+trailingstep
    endif
    if newsl>0 and high-newsl>trailingstep then
    newsl = newsl+trailingstep
    endif
    endif
    if shortonmarket then
    if newsl=0 and tradeprice(1)-low>=trailingstart then
    newsl = tradeprice(1)-trailingstep
    endif
    if newsl>0 and newsl-low>trailingstep then
    newsl = newsl-trailingstep
    endif
    endif
    if barindex-tradeindex>1 then
    if longonmarket then
    if newsl>0 then
    sell at newsl stop
    endif
    if newsl>0 then
    if low crosses under newsl then
    sell at market
    endif
    endif
    endif
    if shortonmarket then
    if newsl>0 then
    exitshort at newsl stop
    endif
    if newsl>0 then
    if high crosses over newsl then
    exitshort at market
    endif
    endif
    endif
    endif
    endif
    
    // market resilience
    once mr=1
    
    if mr then
    starttime = 0       // 08h00 Pré Market EU (Cac, Dax, Footsie, ect...)
    endtime   = 140000  // 09h00 Ouverture session européenne
    if intradaybarindex = 0 then
    hh = 0
    ll = 0
    endif
    
    if time >= starttime and time < endtime then
    if high > hh then
    hh = high
    endif
    if low < ll or ll = 0 then
    ll = low
    endif
    endif
    
    fib38 = hh
    fib0  = ll
    
    fibobull200 = (fib38-fib0)*2.19+fib0
    fibobull162 = (fib38-fib0)*1.59+fib0
    fibobull124 = (fib38-fib0)*0.73+fib0
    fibobull100 = (fib38-fib0)*0.07+fib38
    fibobull76 = (fib38-fib0)+fib38
    fibobull62 = (fib38-fib0)*1.87+fib0
    
    fibobear62 = (fib0-fib38)*0.29+fib0
    fibobear76 = (fib0-fib38)+fib0
    fibobear100 = (fib0-fib38)*0.45+fib0
    fibobear124 = (fib0-fib38)*0.99+fib0
    fibobear162 = (fib0-fib38)*0.67+fib0
    fibobear200 = (fib0-fib38)*0.08+fib0
    
    fibobull200=fibobull200
    fibobull162=fibobull162
    fibobull124=fibobull124
    fibobull100=fibobull100
    fibobull76=fibobull76
    fibobull62=fibobull62
    
    fibobear62=fibobear62
    fibobear76=fibobear76
    fibobear100=fibobear100
    fibobear124=fibobear124
    fibobear162=fibobear162
    fibobear200=fibobear200
    
    if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
    flag1=0
    flag2=0
    flag3=0
    flag4=0
    flag5=0
    flag6=0
    flag7=0
    flag8=0
    flag9=0
    flag10=0
    flag11=0
    flag12=0
    endif
    
    if time>=0 then
    if longonmarket then
    if close crosses over fibobull62 then
    flag1=1
    endif
    if flag1=1 then
    if close crosses under (ll+fibobull62)/2 then
    sell at market
    endif
    endif
    
    if close crosses over fibobull76 then
    flag2=1
    endif
    if flag2=1 then
    if close crosses under (hh+fibobull76)/2 then
    sell at market
    endif
    endif
    
    if close crosses over fibobull100 then
    flag3=1
    endif
    if flag3=1 then
    if close crosses under (fibobull62+fibobull100)/2 then
    sell at market
    endif
    endif
    
    if close crosses over fibobull124 then
    flag4=1
    endif
    if flag4=1 then
    if close crosses under (fibobull76+fibobull124)/2 then
    sell at market
    endif
    endif
    
    if close crosses over fibobull162 then
    flag5=1
    endif
    if flag5=1 then
    if close crosses under (fibobull100+fibobull162)/2 then
    sell at market
    endif
    endif
    
    if close crosses over fibobull200 then
    flag6=1
    endif
    if flag6=1 then
    if close crosses under (fibobull124+fibobull200)/2 then
    sell at market
    endif
    endif
    
    endif
    if shortonmarket then
    if close crosses under fibobear62 then
    flag7=1
    endif
    if flag7=1 then
    if close crosses over (hh+fibobear62)/2 then
    exitshort at market
    endif
    endif
    
    if close crosses under fibobear76 then
    flag8=1
    endif
    if flag8=1 then
    if close crosses over (ll+fibobear76)/2 then
    exitshort at market
    endif
    endif
    
    if close crosses under fibobear100 then
    flag9=1
    endif
    if flag9=1 then
    if close crosses over (fibobear62+fibobear100)/2 then
    exitshort at market
    endif
    endif
    
    if close crosses under fibobear124 then
    flag10=1
    endif
    if flag10=1 then
    if close crosses over (fibobear76+fibobear124)/2 then
    exitshort at market
    endif
    endif
    
    if close crosses under fibobear162 then
    flag11=1
    endif
    if flag11=1 then
    if close crosses over (fibobear100+fibobear162)/2 then
    exitshort at market
    endif
    endif
    
    if close crosses under fibobear200 then
    flag12=1
    endif
    if flag12=1 then
    if close crosses over (fibobear124+fibobear200)/2 then
    exitshort at market
    endif
    endif
    endif
    endif
    endif
    
    // display days in market
    once displaydim   =0  // displays the number of days in market (activated graph)
    once maxdim       =99 // maximum days in market
    if displaydim then
    if not onmarket then
    dim=0
    else
    if onmarket and not onmarket[1] or (longonmarket and shortonmarket[1]) or (shortonmarket and longonmarket[1]) then
    dim=1
    endif
    endif
    if not opendayofweek=0 then
    if onmarket then
    if openday <> openday[1] then
    dim = dim + 1
    endif
    endif
    endif
    if onmarket and dim>=maxdim then
    sell at market
    exitshort at market
    endif
    //graph dim // display days in market
    endif
    
    if not overnightposition then
    if time>=215400 then
    sell at market
    exitshort at market
    endif
    endif
    
    if not weekendposition then
    if (dayofweek=5 and time>=215400) then
    exitshort at market
    sell at market
    endif

    Hi Robertogozzi

    This is the code and running in Hong Kong instrument with HK time.

    It is based on Vectorial strategy and only adjusted the figures for HK.  I have also ran in DJI, DAX, no such issue.

    Sometimes, I used the strategy “Mother of Dragon” in Japan and Singapore instruments, also have this issue.

    Thanks.

    #144755 quote
    GraHal
    Participant
    Master

    running in Hong Kong instrument

    Which Hong Kong instrument?

    Do you mean the Hang Seng Index?

    #144756 quote
    GraHal
    Participant
    Master

    Runs okay for me (no error message etc) on 10k bars on 3 H TF on the Hang Seng … see attached.

    When you confirm what Instrument and TF and No of bars and Timezone  you are having Issues with then I will run same on my Platform for you.

    #144757 quote
    Alfred
    Participant
    Average

    Yes, Hang Seng index

    #144758 quote
    GraHal
    Participant
    Master

    What Timeframe and No of bars and would that be UTC +8?

    #144759 quote
    Alfred
    Participant
    Average

    yes, UTC +8 and 3 min. & 100,000 bar

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

System stopped [defparam] by this code


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Alfred @kin08180213 Participant
Summary

This topic contains 20 replies,
has 4 voices, and was last updated by GraHal
5 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/17/2020
Status: Active
Attachments: 1 files
Logo Logo
Loading...