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?
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.
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?
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:
1
2
3
4
defparampreloadbars=10000
Sma=average[10001,0](close)
buyat-closelimit
graphonpriceSmaAS"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.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue