Autotrading keeps failing: preloadbars not working?

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #217487 quote
    Rufus
    Participant
    Junior

    Hi,

    I get this error:

    The trading system was stopped because the historical data loaded was insufficient to calculate at least one indicator during the evaluation of the last candlestick. You can avoid this in the future by changing the number of preloaded bars with the instruction DEFPARAM (ex: DEFPARAM Preloadbars = 10000).

    However, I have added preload bars… doesn’t seem to change anything, even if I go to 100,000 bars preloaded (which it cannot need).  Any obvious pointers greatly received.

    Thanks

    Rufus

    #217488 quote
    GraHal
    Participant
    Master

    Have a read of this Topic

    Long Time to run System Code Causes Rejection?

    Rufus thanked this post
    #217489 quote
    Rufus
    Participant
    Junior

    Thanks.  I don’t think my code is particularly complicated (probably just inefficient!) and there are sub 200 lines of it.   Three different time frames could be why?  Seems like the only answer for now is to keep submitting?

    #217491 quote
    GraHal
    Participant
    Master

    Does your code get Rejected at the end of the 1st bar when the code first executes?  Put another way … your code does not successfully execute and is always Rejected?

    If Yes to above then submit a Technical Report  via Help > Help Center > I’m having a Technical Problem.

    Rufus thanked this post
    #217492 quote
    Rufus
    Participant
    Junior

    Spot on.  End of first bar.  I will submit a report. Thank you.

    #217528 quote
    Rufus
    Participant
    Junior

    Good morning GraHal,

    I’ve had no response via the submit contact form (couldn’t see the specific route you mentioned).. the problem still exists.  Have you had any resolution?

    #217529 quote
    GraHal
    Participant
    Master

    It has to be a Technical Report submitted via  via Help > Help Center > I’m having a Technical Problem.

    See the top / main toolbar on the PRT Platform?  Far right Help (far left is File) … then follow above.

    I had an acknowledgement and Case Ref on 28 Jun, but no resolution from PRT yet.

    This is why it is good if you / more of us submit a Technical Report for the same symptoms as then PRT may finally realise there is a probem (not just me!) that needs sorting.

    Rufus thanked this post
    #217531 quote
    Rufus
    Participant
    Junior

    Done, thanks for the guidance.  Now the secret sauce is no longer secret! 🙂

    GraHal thanked this post
    #217541 quote
    helsin
    Participant
    Average
    Hello
    I have the same error in several strategies. These have been working without problem for months both live and in demo, but for a few days it has not been possible to work.
    I have sent a request for technical help to the PRT team but for now no response.
    If I find out anything about the issue I will share it in the forum.
    #217544 quote
    GraHal
    Participant
    Master

    helsin did you submit a Technical Report  via Help > Help Center > I’m having a Technical Problem?

    The more of us who send in a Technical Report the more likely they are to do something about the problem.

    #235759 quote
    TimH
    Participant
    New

    Hi all,

    I’m have a similar problem. I reported it to technical support,but just wondering whether anyone has any updates?

    I have a system running on 3 minute TF and 30 minute TF. I have a preloadbars command which should be sufficient as far as I can tell. The error I get is below, and I always get this when first attempting to start the strategy.

    The trading system was stopped because the historical data loaded was insufficient to calculate at least one indicator during the evaluation of the last candlestick. You can avoid this in the future by changing the number of preloaded bars with the instruction DEFPARAM (ex: DEFPARAM Preloadbars = 10000).

    #235784 quote
    TimH
    Participant
    New

    UPDATE – after some further debugging, I found that this statement appears to be the cause of the error.

    OffsetOfLastTrade = BarIndex - TRADEINDEX (1)
    SLPoints = ATRsStopLoss *currentATR [OffsetOfLastTrade ]
    SET STOP PLOSS SLPoints

    It works ok if I remove the offset. So, the following code does work…

    SLPoints = ATRsStopLoss * currentATR
    SET STOP PLOSS SLPoints

    Perhaps when the system first runs, and no trade has happened, the TRADEINDEX(1) is NULL and so can’t be used in a calculation, which kind of makes sense.

    GraHal thanked this post
    #235791 quote
    TimH
    Participant
    New

    UPDATE II

    I got to the bottom of the actual problem (in my case). The code below has a bug which results in the error that says more bars are needed. The reason is that TRADEINDEX(1) returns zero when there are no trades. My offsetOfLastTrade therefore becomes the whole barindex value. When it gets used in the second line of code, currentATR[OffsetOfLastTrade] it throws an error.

    I’m guessing there are similar situations in people’s strategies that also cause this error to be thrown.

    OffsetOfLastTrade = BarIndex - TRADEINDEX (1)
    SLPoints = ATRsStopLoss *currentATR [OffsetOfLastTrade ]
    SET STOP PLOSS SLPoints
    #235793 quote
    robertogozzi
    Moderator
    Master

    Tradeindex, or Tradeindex(1), retains 0 only BEFORE the very first trade, later on it will always retain the BarIndex value of the last operation, so when Not OnMarket it will retain the BarIndex value when the last trade was closed.

    #235795 quote
    GraHal
    Participant
    Master

    Try …

    If OnMarket Then
    OffsetOfLastTrade = BarIndex - TRADEINDEX (1)
    SLPoints = ATRsStopLoss *currentATR [OffsetOfLastTrade ]
    SET STOP PLOSS SLPoints
Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.

Autotrading keeps failing: preloadbars not working?


ProOrder support

New Reply
Author
author-avatar
Rufus @rufus-round Participant
Summary

This topic contains 14 replies,
has 5 voices, and was last updated by GraHal
1 year, 6 months ago.

Topic Details
Forum: ProOrder support
Language: English
Started: 07/10/2023
Status: Active
Attachments: No files
Logo Logo
Loading...