protected override void Initialize() { // if (Instrument.MasterInstrument.InstrumentType == InstrumentType.Currency) Add(Instrument.FullName.ToString(), BarsPeriod.Id, BarsPeriod.Value, MarketDataType.Ask); Add(Instrument.FullName.ToString(), BarsPeriod.Id, BarsPeriod.Value, MarketDataType.Ask); CalculateOnBarClose = false; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (BarsInProgress != 0) return; // Only process the primary bars on the chart. The secondary dataseries is just for reference in the code. if (FirstTickOfBar) Print("Bar:" + CurrentBar + " (Tick:" + Bars.TickCount.ToString() + "), Bar Series: " + BarsInProgress + ", FirstTickOfBar = " + FirstTickOfBar); }
Here is the output from a test strategy:
Bar:30382 (Tick:19), Bar Series: 0, FirstTickOfBar = True
Bar:30383 (Tick:19), Bar Series: 0, FirstTickOfBar = True
Bar:30383 (Tick:18), Bar Series: 0, FirstTickOfBar = True
Bar:30384 (Tick:18), Bar Series: 0, FirstTickOfBar = True
Bar:30384 (Tick:23), Bar Series: 0, FirstTickOfBar = True
Bar:30384 (Tick:3), Bar Series: 0, FirstTickOfBar = True
Bar:30385 (Tick:3), Bar Series: 0, FirstTickOfBar = True
Bar:30385 (Tick:5), Bar Series: 0, FirstTickOfBar = True
Bar:30385 (Tick:1), Bar Series: 0, FirstTickOfBar = True
Bar:30386 (Tick:1), Bar Series: 0, FirstTickOfBar = True
Bar:30386 (Tick:4), Bar Series: 0, FirstTickOfBar = True
Bar:30386 (Tick:12), Bar Series: 0, FirstTickOfBar = True
Bar:30386 (Tick:14), Bar Series: 0, FirstTickOfBar = True
Bar:30386 (Tick:10), Bar Series: 0, FirstTickOfBar = True
Bar:30387 (Tick:10), Bar Series: 0, FirstTickOfBar = True
Bar:30388 (Tick:10), Bar Series: 0, FirstTickOfBar = True
Bar:30388 (Tick:2), Bar Series: 0, FirstTickOfBar = True
Bar:30389 (Tick:2), Bar Series: 0, FirstTickOfBar = True
Bar:30389 (Tick:5), Bar Series: 0, FirstTickOfBar = True
I have attached an example strategy you can run to show what's happening. Put it on a new 1 minute chart. I used both ES and $EURUSD and they both produced this result.
1) Why is FirstTickOfBar not true on the first tick of the bar?
2) Why is FirstTickOfBar true for more than one tick in the same bar?
Thanks!
Bryan
Comment