Max. hist. bars in a strategy

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #237950 quote
    JS
    Participant
    Senior

    Hi,

    I use the “IntraDayBarIndex” in my strategy to calculate certain indicators, the “IntraDayBarIndex” can reach a value of 75,000 (TF=1 sec)) during a day.

    I know that the maximum number of bars to load is 10,000 (DefParam PreLoadBars=10000).

    When you use “DefParam PreLoadBars=10,000” in your strategy, does the number of loaded bars always remain constant 10,000?

    So, when the strategy is running, and new bars are added, are the oldest bars, when the number exceeds 10,000, removed or not?

    #237953 quote
    robertogozzi
    Moderator
    Master
    Good question, I have no idea, though. I wrote this code:
    defparam preloadbars = 10000
    buy at -close limit
    graph barIndex
    graph IntraDayBarIndex
    graph IsLastBarUpdate
    to be able to see data on my chart, so I could figure out what it is all about. The attached screenshot reports what I found out:
    • Pic 1 is the screenshot I took when the mouse was sitting on the leftmost candle (the very first one) and it shows BARINDEX=10000, while the indicator reads BARINDEX=0 .
    • Pic 2 is the screenshot I took when the mouse was sitting on a later bar where it shows BARINDEX=20001, while the indicator reads BARINDEX=10001.
    So, I assume the 10K preloaded bars are kept in memory.
    Iván González thanked this post
    Preloaded-Bars.jpg Preloaded-Bars.jpg
    #237955 quote
    robertogozzi
    Moderator
    Master
    The indicator is simply:
    RETURN BarIndex AS "BarIndex"
    #237958 quote
    JS
    Participant
    Senior

    Thanks Roberto…

    If this works the same for strategies and a maximum of 10k bars remains in memory, then the “IntraDayBarIndex” will never get a higher value than 10,000…? (“IntraDayBarIndex” depends on the number of bars loaded)

    Does it mean that a calculation involving more than 10,000 bars is no longer correct?

    #237977 quote
    robertogozzi
    Moderator
    Master
    Using this code in ProBuilder:
    RETURN IntraDayBarIndex AS "IntraBarIndex",BarIndex AS "BarIndex"
    I could figure out that IntraDayBarIndex tallied a total 34772 intraday bars, but many are missing (on a 1-second TF that happens often), as from Pic 1. SMA10001 is plotted starting from bar 10000, as the first 10K bars (0-9999) were not enough for the calculations, as from Pic 2.
    This code, in ProBacktest:
    defparam preloadbars = 10000
    Sma = average[10001,0](close)
    buy at -close limit
    graphonprice Sma AS "Sma 10001"
    uses the same SMA10001 and starts graphing it from bar 10000 (using 10001 bars, 0-10000), which is bar 0 in ProBuilder, due to the 10K preloaded bars, as from Pic 3. If a change it to SMA10002 it is graphed from bar 10001 as it needs an additional bar for the calculations, as from Pic 4.
    We can assume that both ProBacktest/ProOrder and ProBuilder only plot accurate data when there are enough bars for the calculations. If you use defparam preloadbars = 0, then ProBacktest will graph the SMA10001 starting from bar 10000, i.e. you won’t get any signal (in case you expect a crossover) until 10K+ bars have elapsed. No incorrect calculations seem to be made.
    inverse and JS thanked this post
    Pic-1.jpg Pic-1.jpg Pic-2.jpg Pic-2.jpg Pic-3.jpg Pic-3.jpg Pic-4.jpg Pic-4.jpg
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Max. hist. bars in a strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
JS @js Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by robertogozzi
1 year, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/23/2024
Status: Active
Attachments: 5 files
Logo Logo
Loading...