MultiTimeFrame PreLoadBars Error Message?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #116596 quote
    Ξ3
    Participant
    Average

    Hi All,

    Please could someone assist in answering some questions on the PreLoadBars function when using MultiTimeFrame in ProOrder?

    I am attempting to automate a 1 hour system and run it in a significantly lower timeframe (read 1 minute or even 1 second). Back testing seems to be working well but when I try to run it live on IG’s ProRealTime version 10.3, I get the following error message: “This trading system was stopped because the historical data loaded was insufficient to calculate at least one indicator during the evaluation of the last candlestick.”

    My PreLoadBars are already set to the maximum of 10,000 so my questions are:

    1. Is there a way to create a dummy indicator in my code, purely to pass this test (to trick ProOrder somehow)? The idea is then to restrict trading until such time that enough candlesticks are available (built up over time) in order for there to be enough data available in the shorter MTF to satisfy the requirements of candlesticks in the longer MTF?
    2.  Can this historical data be built up over time or is there a hard limit of only looking back a maximum of 10,000 bars in the shorter MTF?
    3.  Does ProRealTime version 11 cater for a larger value for PreLoadBars for ProOrder in order to cater for MultiTimeFrame data requirements?

    Many thanks.

    #116622 quote
    Ξ3
    Participant
    Average

    Hi All,

    Perhaps the error message is misleading as I found the following link mentioning that a phantom bar may be causing a divide by zero error: https://www.prorealcode.com/topic/trading-system-automatically-stopped/

    I am now going through my code with a fine toothcomb trying to find a possible divide by zero exception.

    Strange that this is not a problem during back-testing?

    #116758 quote
    GraHal
    Participant
    Master

    Strange that this is not a problem during back-testing?

    I wrote a comment to above and then thought it would be more usefully posted in the Forum on the link below

    https://www.prorealcode.com/topic/centralization-of-queries-and-suggestions-on-prorealtime/page/20/#post-116756

    Ξ3 thanked this post
    #116769 quote
    Ξ3
    Participant
    Average

    Hi GraHal,

    Thanks for the link, I fully agree with your sentiments! I have spent the last day debugging my code and running it live (stopping and restarting the strategy each time I make a debug change) line by line until it starts failing.

    I finally tracked it down to the following lines in my code which seem to be failing due to the longer MultiTimeFrame not having sufficient data for the shorter MTF check. I have tried coding around this by checking for “undefined” and/or other “if” statements but so far to no avail, which brings me back to my questions above. This part of my code gets executed in a 1 hour block of a 1 second MTF strategy.

    // -> Reversion Power (RSI)
    ReversionPowerLimit = 15
    RK5 = WeightedAverage[3]((RSI[5](MesaInput) - Lowest[5](RSI[5](MesaInput))) / (Highest[5](RSI[5](MesaInput)) - Lowest[5](RSI[5](MesaInput)))) * 100
    RK14 = WeightedAverage[3]((RSI[14](MesaInput) - Lowest[14](RSI[14](MesaInput))) / (Highest[14](RSI[14](MesaInput)) - Lowest[14](RSI[14](MesaInput)))) * 100
    RK45 = WeightedAverage[14]((RSI[45](MesaInput) - Lowest[45](RSI[45](MesaInput))) / (Highest[45](RSI[45](MesaInput)) - Lowest[45](RSI[45](MesaInput)))) * 100
    RK75 = WeightedAverage[20]((RSI[75](MesaInput) - Lowest[75](RSI[75](MesaInput))) / (Highest[75](RSI[75](MesaInput)) - Lowest[75](RSI[75](MesaInput)))) * 100
    WeightedRK = ((4.1 * RK5) + (2.5 * RK14) + (RK45) + (4 * RK75)) / 11.6
    AverageWeightedRK = WeightedAverage[SignalCycle](WeightedRK)
    

    If you can think of a way around this problem, don’t hesitate to share your thoughts 😉

    #116783 quote
    GraHal
    Participant
    Master

    Have you tried the shorter TF at 5 seconds?

    1 second TF may just not be long enough to read all your code and execute a trade (esp if many lines and complex?) and then start reading again on the next second?

    Worth a try anyway?

    #116815 quote
    Ξ3
    Participant
    Average

    Thanks GraHal,

    I will give that a try but my hopes are tempered as I think I tried a 1 min, 5 min and 30 min timeframe at one stage without success.

    #116842 quote
    Ξ3
    Participant
    Average

    Hi All,

    At least my story ends well as I have managed to get the automated trading code running stable again.

    Just a warning to anyone reading this thread: You should not always trust the exception messages that ProOrder returns upon failure. Sometimes “This trading system was stopped because the historical data loaded was insufficient to calculate at least one indicator during the evaluation of the last candlestick” means exactly what it says. Other times it may mean that there is a divide by zero error or a phantom bar causing the problem, as highlighted by GraHal in another thread. In my case, as far as I can tell, ProOrder sometimes doesn’t handle MultiTimeFrame strategies as expected. On this note also just a reminder that the BarIndex in various portions of a MTF strategy will be different depending on the time block that you are in. Anyway, what finally fixed my issue was changing my code above to: (Basically forcing an initialisation of some variables)

    // -> Reversion Power (RSI)
    ReversionPowerLimit = 15
    If BarIndex > MinBarsRequired then
       RK5 = WeightedAverage[3]((RSI[5](MesaInput) - Lowest[5](RSI[5](MesaInput))) / (Highest[5](RSI[5](MesaInput)) - Lowest[5](RSI[5](MesaInput)))) * 100
       RK14 = WeightedAverage[3]((RSI[14](MesaInput) - Lowest[14](RSI[14](MesaInput))) / (Highest[14](RSI[14](MesaInput)) - Lowest[14](RSI[14](MesaInput)))) * 100
       RK45 = WeightedAverage[14]((RSI[45](MesaInput) - Lowest[45](RSI[45](MesaInput))) / (Highest[45](RSI[45](MesaInput)) - Lowest[45](RSI[45](MesaInput)))) * 100
       RK75 = WeightedAverage[20]((RSI[75](MesaInput) - Lowest[75](RSI[75](MesaInput))) / (Highest[75](RSI[75](MesaInput)) - Lowest[75](RSI[75](MesaInput)))) * 100
    Else
       RK5 = 0
       RK14 = 0
       RK45 = 0
       RK75 = 0
    EndIf
    WeightedRK = ((4.1 * RK5) + (2.5 * RK14) + (RK45) + (4 * RK75)) / 11.6
    AverageWeightedRK = WeightedAverage[SignalCycle](WeightedRK)

    Good trading to all and once again thanks to GraHal for the support!

    GraHal and TradSuz thanked this post
    #116843 quote
    GraHal
    Participant
    Master

    my hopes are tempered as I think I tried a 1 min, 5 min and 30 min timeframe at one stage without success.

    Your current short TF is 1 sec so I was suggesting try 5 seconds TF … so I guess above you meant to say 1 sec, 5 sec and 30 sec??

    #116844 quote
    Ξ3
    Participant
    Average

    Actually, I did mean the longer timeframes I mentioned (1, 5 & 30min) just to give the 1 hour timeframe enough bars to calculate my indicators considering the PreLoadBars maximum of 10,000. But your times frames (1, 5 & 30 secs) now also works even if I have to run it for a little while to provide the 1 hour timeframe with enough bars to start calculating the indicators correctly 😉

    As IG currently only provides ProRealTime version 10.3, I still have one last open question on ProRealTime version 11, especially considering that I read somewhere that the “new” back-testing now caters for a 1 million bar lookback…

    Does ProRealTime version 11 cater for a larger value for PreLoadBars for ProOrder in order to cater for MultiTimeFrame data requirements?

    GraHal thanked this post
    #116868 quote
    Nicolas
    Keymaster
    Master

    When using MTF in a strategy, the Preloadbars will load maximum 10k bars for all timeframes declared in the code. But, bear in mind that calculation will start at the first bar of the default timeframe (the shorter one).

    However, even with 1M bars, as that it will be possible with v11, I don’t think that it is necessary to get more than 10k bars preloaded, the principle of testing strategy will be the same as now, despite the fact that we will have more history available.

    Ξ3 thanked this post
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

MultiTimeFrame PreLoadBars Error Message?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Ξ3 @cbeukes Participant
Summary

This topic contains 9 replies,
has 3 voices, and was last updated by Nicolas
6 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/13/2020
Status: Active
Attachments: No files
Logo Logo
Loading...