Preload bars error message

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #104865 quote
    Slowlyslowly
    Participant
    Average

    Hi

     

    Even after i increase the defparam preloadbars = 5000 i still get the error message and my automatic code is rejected. I have tried setting to 0 and also removed it totally and my code still stops. The error message is the basic …please increase the number off preloaded bars with instruction DEFPARAM etc etc

     

    Code works fine on back test – has also previously worked as automatic code before i have increase some filters in the code which is now causing the problem.

    #104866 quote
    robertogozzi
    Moderator
    Master

    Try to increase to 10,000 (max. allowed).

    In case you use very high period numbers for indicators, try decreasing them.

    As a final resort you should post your full code to be able to replicate those messages.

    #104871 quote
    Slowlyslowly
    Participant
    Average
    Roberto , detailed code below as tried the solutions and still rejects code.
    
    
    
    
    
    
    
    
    //pending orders version
    //version (c):
    //mid bollinger cancel and closing time of pending orders
    //version (d):
    //max loss + breakeven + std conditions
    
    defparam flatafter=205500 //close opened orders and delete pending ones at that time
    defparam cumulateorders=false
    defparam preloadbars= 10000
    
    // --- settings
    amount = 3 //amount of contract/lot/shares to open for each order
    StartTime = 143000 //start time of the strategy to look for a spike outside BB
    EndTime = 205500 //end time of the strategy
    BreakAboveBelowBB = 2//Break above/below BB (3points)
    BreakBarDistance = 2//Break below low/high of reference bar (2points)
    StopL = 1//Stop (2 point break of reference bar)
    TargetP = 95 //Target (Mid Bollinger 95%)
    MinTarget = 8//Minimum target for NO trade(10 points)
    MaxLoss = tp  //Maximum loss in points for any order
    BreakevenStart = 60//breakeven activation at x% of target achieved
    PointsToKeep = 5 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
    MaxSTD = 14 //max standard deviation level to activate/cancel the orders
    STDperiod = 10//standard deviation period used for calculation
    MaxADX = 18
    ADXperiod = 16
    adxp=adxp
    indicator1 = ADX[adxp]
    indicator2 = ADXR[adxp]
    c1 = (indicator1 < indicator2)
    
    
    
    // Conditions to enter short positions
    indicator3 = ADX[adxp]
    indicator4 = ADXR[adxp]
    c2 = (indicator3 < indicator4)
    
    
    // --- end of settings
    
    tcondition = opentime>=starttime and time<=endtime
    dcondition = OpenDayOfWeek = 6
    bbup = BollingerUp[20](close)
    bbdn = BollingerDown[20](close)
    mid = average[20]
    istd = std[STDperiod]
    iadx = adx[ADXperiod]
    //reset ref bar
    if longonmarket then
    hhrefbar=0
    endif
    if shortonmarket then
    llrefbar=0
    endif
    if not tcondition then
    hhrefbar=0
    llrefbar=0
    endif
    if not longonmarket and hhrefbar>0 and high crosses over mid then
    hhrefbar=0
    endif
    if not shortonmarket and llrefbar>0 and low crosses under mid then
    llrefbar=0
    endif
    
    if tcondition and not dcondition then
    if not shortonmarket then
    //find first new BB+ ref bar = SHORT ORDER
    if llrefbar=0 then //first ref
    if high>=bbup+BreakAboveBelowBB*pointsize then
    ll=low
    sellsl=high+StopL*pointsize
    llrefbar=barindex
    lastref=-1
    endif
    else //next ref
    if high>high[max(1,barindex-llrefbar)] then //compute new reference bar
    ll=low
    sellsl=high+StopL*pointsize
    llrefbar=barindex
    lastref=-1
    endif
    endif
    endif
    if not longonmarket then
    //find first new BB- ref bar = BUY ORDER
    if hhrefbar=0 then //first ref
    if low<=bbdn-BreakAboveBelowBB*pointsize then
    hh=high
    buysl=low-StopL*pointsize
    hhrefbar=barindex
    lastref=1
    endif
    else //next ref
    if low<low[max(1,barindex-hhrefbar)] then //compute new reference bar
    hh=high
    buysl=low-StopL*pointsize
    hhrefbar=barindex
    lastref=1
    endif
    endif
    endif
    //break ref bar and open orders
    //case buy
    if not longonmarket and lastref>=0 and barindex>=hhrefbar and hhrefbar>0 then //and high>=hh+BreakBarDistance*pointsize then
    avg = average[20](close)
    tp = (avg-(hh+BreakBarDistance*pointsize))*(TargetP/100)
    allowtarget = tp>=MinTarget*pointsize
    if allowtarget and istd<maxstd*pointsize or iadx<maxadx and c1 then
    buy amount contract at hh+BreakBarDistance*pointsize stop
    //hhrefbar=0 //reset ref bar
    set stop loss min(maxloss*pointsize,close-buysl)
    set target profit tp
    endif
    endif
    //case sell
    if not shortonmarket and lastref<=0 and barindex>=llrefbar and llrefbar>0 then // and low<=ll-BreakBarDistance*pointsize then
    avg = average[20](close)
    tp = ((ll-BreakBarDistance*pointsize)-avg)*(TargetP/100)
    allowtarget = tp>=MinTarget*pointsize
    if allowtarget and istd<maxstd*pointsize or iadx<maxadx and c2 then
    sellshort amount contract at ll-BreakBarDistance*pointsize stop
    //llrefbar=0 //reset ref bar
    set stop loss min(maxloss*pointsize,sellsl-close)
    set target profit tp
    endif
    endif
    endif
    
    
    startBreakeven = (BreakevenStart/100)*tp //how much pips/points in gain to activate the breakeven function?
    
    //reset the breakevenLevel when no trade are on market
    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 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 ---
    
    // --- SELL SIDE ---
    //test if the price have moved favourably of "startBreakeven" points already
    IF SHORTONMARKET AND tradeprice(1)-close>=startBreakeven 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
    // --- end of SELL SIDE ---
    
    //graph tp
    //graph hh+BreakBarDistance*pointsize coloured(0,255,0) as "reference buy"
    //graph ll-BreakBarDistance*pointsize coloured(255,0,0) as "reference sell"
    //graph allowtarget
    //graph close as "price Close"
    //graph not longonmarket and hhrefbar>0 and high crosses over mid
    //graph breakevenlevel
    
    #104874 quote
    robertogozzi
    Moderator
    Master

    I tested your code on Eur/Usd, 5-minute TF, and I get no error, no matter what PRELOADBAR I write.

    It runs smoothly. Backtest is very slow, instead!

    #104875 quote
    robertogozzi
    Moderator
    Master

    Try shutting down your platform and reopen it, even after restarting your PC.

    #104878 quote
    Slowlyslowly
    Participant
    Average

    Restarted everything and reloaded and error happens again .

    I can back test no problem with the code without errors its when i then put it live – it loads it then rejects it after a few minutes.

    im running it on the DOW on 1 and 3 minute time frames.

    #104881 quote
    robertogozzi
    Moderator
    Master

    It must be due to extremely slow code, but I could not spot why.

    I suggest that you use Ctrl+M from the platform to ask assistance.

    #104886 quote
    GraHal
    Participant
    Master

    Backtest is very slow, instead!

    I agree … maybe the OP just chose the wrong Username! 🙂 🙂

    I will try it on Demo Forward test and Report back!

    EDIT / PS

    Yep rejected 3 times with and without the PreLoad bars I get same error message  … Increase PreLoad bars etc etc.

    #104890 quote
    GraHal
    Participant
    Master

    I reckon it’s timing out on Forward Test (code taking too long etc) and the error message is meaningless?

    On Backtest there is probably a longer time out period and that is why the code eventually gets there in Backtest??

    Basis for an easy worded Tech Report? I suggest …

    • System won’t run on Forward Test … please can you tell me why?
    #104891 quote
    Slowlyslowly
    Participant
    Average

    So u suggest I ask tech support with that so I therefore will with yr suggested comments . back testing is very slow due to all the requirements it has to test … let’s see if they have a solution .. ?  Seems strange to me

    #104892 quote
    GraHal
    Participant
    Master

    Yeah we all learn more when we make mistakes, we need to know what the limits are on time for code to run and PRT may learn something also during the investigation ?

    It may be something simple anyway that is making it real slow?

    Results (attached)  look promising on DJI 1M, spread = 4 attached so it is worth keeping the code as is  if it will run okay?

    Press Ctrl + M when you are seeing a Chart on the screen and follow the bottom option … Tech Report.

    Slow.jpg Slow.jpg
    #104913 quote
    Nicolas
    Keymaster
    Master

    There is no reason to extend the preloadbars according to the code, I don’t understand why you get that error message. BTW, that code reminds me something 😉

    #104919 quote
    GraHal
    Participant
    Master

    There is something odd about that code even outside of PRT … as soon as have it up on my screen in this Forum and I am scrolling over the code … my scroll button works real slow like when I am running out of RAM.

    I reckon it’s that Username the OP has … he’s jinxed himself!!! (joke! 🙂 )

    But not joking about the slow mouse scroll.

    #105070 quote
    GraHal
    Participant
    Master

    Any reply from PRT yet @Slowlyslowly??

    It’s still doing the same type Rejection due to not enough data history etc.

    I am curious if it will make money if we get it going!!?? 🙂

    #105637 quote
    GraHal
    Participant
    Master

    Just spent the last hour or so removing various snippets / conditions / variables etc in an effort to stop this System being rejected and showing an error message that has nothing to do with the rejection!

    Below is the fix. Seems it maybe was timeout error as I had suggested above?

    Code was using ADXPeriod and ADXp for the same value, but ADXp was not defined anywhere in the code.

    Line 36 
    adxp=adxperiod (not adxp=adxp)
    
    Slowlyslowly thanked this post
Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.

Preload bars error message


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 16 replies,
has 4 voices, and was last updated by Nicolas
6 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/16/2019
Status: Active
Attachments: 1 files
Logo Logo
Loading...