Can you please help me understanding how the data is calculated on multiple time frame indicators with below example?
I have created simple indicator with only print statement in OnBarUpdate()
Step 1:
protected override void Initialize()
{
CalculateOnBarClose = false;
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 0)
{
Print("Test "+BarsInProgress+" "+CurrentBar+" "+Time[0]);
}
}
When I apply this indicator to 5 min chart with Load Data as custom range between dates and scroll back to first day of data in the chart, clear the output and hit F5.
Out put window is displaying bar numbers that are visible in the chart and when i press right arrow it is printing bar by bar as expected as soon as hit right arrow one bar at a time.
Adding secondary bars to indicator:
protected override void Initialize()
{
CalculateOnBarClose = false;
Add(PeriodType.Tick, 1);
}
No changes to OnBarUpdate
When I hit F5, it is printing all the bars in custom range between dates that was chosen while creating the chart rather than just printing bars on the chart.
Is this the expected behavior? Is there a way to execute code only for the bars on the chart and calculate rest of the bars only when they are visible on the chart(after pressing right arrow key)?
thanks,
Comment