The custom indicator loads a 1-minute time frame dataseries.
I am needing to process data on every 1-minute bar in the OnBarUpdate() method. However, it seems that it only processes the added data series for a few days back and not all the data loaded within the chart.
I've tried setting the "MaximumBarsLookBack", changing the "Calculate" to be each tick, etc without change.
I am loading multiple weeks of data into the chart, but only a few days of 1-min data are processed.
How do I allow OnBarUpdate() to be called for each 1-min bar (the entire time span of the chart) of the secondary dataseries? Do I need to add something to AddDataSeries()? Change a default setting of the chart/indicator?
Thank you!
using NinjaTrader.Gui.Chart;
using NinjaTrader.Data;
namespace NinjaTrader.NinjaScript.Indicators
{
public class ExampleMultiTimeFrameOnBarUpdate : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Perform a calculation on each 1-min bar, regardless of primary dataseries.";
Name = "Test - Multi-timeframe OnBarUpdate()";
Calculate = Calculate.OnEachTick;
IsOverlay = true;
DrawOnPricePanel = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
IsSuspendedWhileInactive = true;
MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
}
else if (State == State.Configure)
{
AddDataSeries(BarsPeriodType.Minute, 1);
}
}
protected override void OnBarUpdate()
{
//if (BarsInProgress == 1)
Print("BiP " + BarsInProgress + " " + Times[BarsInProgress][0]);
}
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
base.OnRender(chartControl, chartScale);
}
}
}
Comment