Stratergy is closing on first close

Forums ProRealTime English forum ProOrder support Stratergy is closing on first close

Viewing 15 posts - 1 through 15 (of 15 total)
  • #219606

    I have a new version off a stratergy that works good on back testing, but when i run it live i says that one idicator cant be loaded and i shuld increse preloadbars to 10000. My longest counting idicator is an Average500 and doing this wont help.

    What can be the reason?

    Whats been added since previus versions is adding this code:

    ENTRYBAR = BarIndex – TRADEINDEX[0]

    LP75ATENTRY = LP75[ENTRYBAR]

    HP75ATENTRY = HP75[ENTRYBAR]

    LP500ATENTRY = LP500[ENTRYBAR]

    HP500ATENTRY = HP500[ENTRYBAR]

    HP*/LP* is respective versions off this:

    HP75 = (HIGHEST[HP2](CLOSE)-LOWEST[HP2](CLOSE)) + LOWEST[HP2](CLOSE)

     

    #219607

    i shuld increse preloadbars to 10000

    You should try above first as it is easy to try as a fix.

    #219608

    I tryed but it makes no difference and still gives the same 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).

     

    2-3 seconds before the first bar is about to close it quits. But when back testing everythings works like normal.

    #219609

    I think you would need to post your full code for anybody to add any meaningful suggestions to help.

    I’ve had a few recently of the same Reported Error as you are seeing and which turned out to be nothing to do with ‘not enough historical’ bars etc. See the link below  …

    https://www.prorealcode.com/topic/long-time-to-run-system-code-causes-rejection/#post-216815

     

    #219611

    ENTRYBAR = BarIndex – TRADEINDEX[0], on the first bar (with 10000 preloaded bars), will evaluate to 10000 – 0 = 10000.

    Try using DEFPARAM PreLoadBars = 0.

    1 user thanked author for this post.
    #219651

    ENTRYBAR = BarIndex – TRADEINDEX[0], on the first bar (with 10000 preloaded bars), will evaluate to 10000 – 0 = 10000.

    Try using DEFPARAM PreLoadBars = 0.

    Tryed this now but still dont work.

    clerad upp the code a bitt, but same error.

    ENTRYBARlong = BarIndex – TRADEINDEX

    ENTRYBARshort = BarIndex – TRADEINDEX

    LP75ATlong = LP75[ENTRYBARlong]

    HP75ATlong = HP75[ENTRYBARlong]

    LP75ATshort = LP75[ENTRYBARshort]

    HP75ATshort = HP75[ENTRYBARshort]

    LP500ATlong = LP500[ENTRYBARlong]

    HP500ATlong = HP500[ENTRYBARlong]

    LP500ATshort = LP500[ENTRYBARshort]

    HP500ATshort = HP500[ENTRYBARshort]

     

    I think you would need to post your full code for anybody to add any meaningful suggestions to help.

    I’ve had a few recently of the same Reported Error as you are seeing and which turned out to be nothing to do with ‘not enough historical’ bars etc. See the link below …

    https://www.prorealcode.com/topic/long-time-to-run-system-code-causes-rejection/#post-216815

    Read that tread but dident find any solution?

    Thanks for the quick help 🙂

    #219714

    Sorry for mispelling TRADEINDEX, it always requires parentheses, not brackets, such as graph TRADEINDEX(0).

    In case of (0), it can be omitted.

     

    #219719

    Another source of error could be the timeframes involved.

    If you are calculating the Average500 on a 1-hour timeframe, but your default TF is 1-minute, then it will need 500*60-minute preloaded bars, which yields 30K bars, thus exceeding the max preloaded bars limit. Of cource that tally will even be greater if you calculate the indicator on a greater TF (even a 30-minute TF should exceed the limit, as 500*30 minutes = 15K).

    Try reducing 500 one step at a time to reach an acceptable limit.

     

    #219721

    Tryed it with Tradeindex – barindex too, no () or []. Same error in live traiding.

    Im on one time frame only, its all in the 10min graf.

    Just tryed it with preloadbars=0 and same error.

    My standard from before was preloadbars=1000.

    The purpuse off the code is to use the value off LP75 (lowest close off past 75 bars) at entry off a long position as a exit, and other things.. It works as intenden in backtesting.

    I sent an error repport and email to PRT support, but will keep trying.

    #219722

    Try adding below directly under your Defparam’s.

    As a test, just try it to see if the Rejection / System stoppages cease?

    #219725

    Will try it later (cant gett on my computer at the moment)

    Must be something on the backend that stopps it on live when i asign variable to a variabel instead of a specific bar.

    Its the only things thats differnet from before.

    Earlyer versions that dont have this works and is running live now.

    I have an IG account btw.

    #219742

    Try adding below directly under your Defparam’s.

    As a test, just try it to see if the Rejection / System stoppages cease?

    Same result when i try to force buy, crasches before it places an order.

    Havent learn how to work with arrays, have anyone tryed that to gett around this problem?

    Im out off ideas so will wait for what the support team says.

    #219749

    Post their answer, whenever you get one. It could help.

     

    #219790

    Found a solution to my problem.

    ENTRYBARlong = BarsSince(LongTriggered[1])

    ENTRYBARshort = BarsSince(ShortTriggered[1])

     

    Instead off Barindex – Tradeindex i use BarsSince and then gott a new error message:

    The trading system was stopped because the program used a negative or zero offset (ex: close[-10]) during the evaluation of the last candlestick. You can add protections to your code to prevent negative or zero offsets then backtest the system to check the correction.

    So i added this code so ENTRYBARlong/short wont be zero:

    IF ENTRYBARlong < 1 THEN
    ENTRYBARlong = 1
    ENDIF

    IF ENTRYBARshort < 1 THEN
    ENTRYBARshort = 1
    ENDIF

    Only tested the stratergy in a 1min graf for 2 bars so see if its runing, so dont know longer term yet. But it seems to have fixed the problem.

    2 users thanked author for this post.
    #220293

    Gott this reply from the support them, so inline with the sulution i found.

    Thank you for your feedback. Here is the reply of our Coding team regarding what might have been the issue: they assume it comes from those two lines:
    ENTRYBARlong = BarIndex – TRADEINDEX
    ENTRYBARshort = BarIndex – TRADEINDEX

    at the beginning of the computations since there haven’t been any trades yet, so tradeindex=0 and entrybarlong=entrybarshort=barindex.
    If the following instructions calculations’ fail on the first candle of the history, this could explain why the strategy got interrupted.

    1 user thanked author for this post.
Viewing 15 posts - 1 through 15 (of 15 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login