I am adding a second data series with Data.BarsPerioType.Tick of the primary instrument so that I have single tick data for accuracy. Normally I develop my strategies at a higher time period for velocity of development, such as minutes or seconds, then do precise backtesting with tick data to have the most accurate results.
Ideally I set the data series in the Strategy Analyzer to a larger timeframe such as 5 minutes so that I can easily look at the strategy analyzer chart, and then add a secondary data series in the strategy's OnStateChange configure to ticks. That way, I can run my strategy on tick-precision updates while viewing the chart with minutes.
Unfortunately, what I am observing is that when I add 1-tick data series to the strategy analyzer is that it's not actually calling OnBarUpdate at 1-ticks. I use
AddDataSeries(Data.BarsPeriodType.Tick, 1);
If the strategy analyzer Data series is set to the following, I see that OnBarUpdate is called 6358910 times for BOTH BarsInProgress == 0 and BarsInProgress == 1.
Instrument = NQ 06-23
Type = Tick
Value = 1
However, if I set the strategy analyzer Data series to the following, I see that OnBarUpdate is called 3192955 times for BOTH BarsInProgress == 0 and BarsInProgress == 1.
Instrument = NQ 06-23
Type = Minute
Value = 1
The question I have is, how can I add a data series in OnStateChangeConfigure with ticks and get OnBarUpdate to run on each tick?
Code below to reproduce.
protected override void OnStateChange()
{
if (State == State.Configure)
{
startTime = DateTime.Now;
// Add tick data to BarsInProgress == 1
AddDataSeries(Data.BarsPeriodType.Tick, 1);
}
}
int[] tickAry = new int[2];
protected override void OnBarUpdate()
{
tickAry[BarsInProgress]++;
}
void OnTermination() // i call this at the end of the strategy analyzation
{
for (int i = 0; i < tickAry.Length; i++)
{
Print("tickAry[" + i + "] = " + tickAry[i]);
}
}

Comment