On an indicator, this function returns 1 on candlesticks updated in real-time (or the last candlestick on a closed instrument), otherwise it returns 0.

On a backtest, this function returns 1 starting at the date the backtest was started. It is equal to 0 on the historical data preloaded by the backtest (PreLoadBars).

The instruction helps a lot to reduce drastically the loading times of an indicator. It prevents the code to be read and executed of each bar of the history.

For example, here is a code that plots rectangles of the down gaps between the time that they happened to the last bar on the chart, from the last X periods:

The code makes a loop over 1 thousand bars, 1 time when the indicator is applied on the chart and anytime the last bar on the chart is updated, therefore the code is ran instantly with no loading times.

This example in video is more visual on how it can improves loading times:

 

Share this