After PercentComplete is set to 1.0 I can still see an update of the current bar. The following code can demonstrate the behavior:
namespace NinjaTrader.NinjaScript.Indicators { public class Test : Indicator { protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Indicator is used for testing purpose"; Name = "Test"; Calculate = Calculate.OnEachTick; IsOverlay = true; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; IsSuspendedWhileInactive = true; } } protected override void OnBarUpdate() { if (BarsInProgress != 0) { return; } if (CurrentBar < Bars.Count - 1) { return; } if (Bars.PercentComplete >= 1) { Print ("Current time = " + DateTime.Now + " PercentComplete = " + this.Bars.PercentComplete + " BarID = " + CurrentBar + " Bar Time = " + this.Bars.GetTime (CurrentBar) + " Last Chart Bar = " + Time[0].ToString ()); } } } }
Printout:
Current time = 11-12-2018 15:18:00 PercentComplete = 1 BarID = 500 Bar Time = 11-12-2018 15:18:00 Last Chart Bar = 11-12-2018 15:18:00
Current time = 11-12-2018 15:18:01 PercentComplete = 1 BarID = 500 Bar Time = 11-12-2018 15:18:00 Last Chart Bar = 11-12-2018 15:18:00
Current time = 11-12-2018 15:18:01 PercentComplete = 1 BarID = 500 Bar Time = 11-12-2018 15:18:00 Last Chart Bar = 11-12-2018 15:18:00
Current time = 11-12-2018 15:18:02 PercentComplete = 1 BarID = 500 Bar Time = 11-12-2018 15:18:00 Last Chart Bar = 11-12-2018 15:18:00
Current time = 11-12-2018 15:18:02 PercentComplete = 1 BarID = 500 Bar Time = 11-12-2018 15:18:00 Last Chart Bar = 11-12-2018 15:18:00
Current time = 11-12-2018 15:18:02 PercentComplete = 1 BarID = 500 Bar Time = 11-12-2018 15:18:00 Last Chart Bar = 11-12-2018 15:18:00
Current time = 11-12-2018 15:18:03 PercentComplete = 1 BarID = 500 Bar Time = 11-12-2018 15:18:00 Last Chart Bar = 11-12-2018 15:18:00
Current time = 11-12-2018 15:19:00 PercentComplete = 1 BarID = 501 Bar Time = 11-12-2018 15:19:00 Last Chart Bar = 11-12-2018 15:19:00
Current time = 11-12-2018 15:19:00 PercentComplete = 1 BarID = 501 Bar Time = 11-12-2018 15:19:00 Last Chart Bar = 11-12-2018 15:19:00
Current time = 11-12-2018 15:19:01 PercentComplete = 1 BarID = 501 Bar Time = 11-12-2018 15:19:00 Last Chart Bar = 11-12-2018 15:19:00
Current time = 11-12-2018 15:19:01 PercentComplete = 1 BarID = 501 Bar Time = 11-12-2018 15:19:00 Last Chart Bar = 11-12-2018 15:19:00
Current time = 11-12-2018 15:19:02 PercentComplete = 1 BarID = 501 Bar Time = 11-12-2018 15:19:00 Last Chart Bar = 11-12-2018 15:19:00
Current time = 11-12-2018 15:19:02 PercentComplete = 1 BarID = 501 Bar Time = 11-12-2018 15:19:00 Last Chart Bar = 11-12-2018 15:19:00
Current time = 11-12-2018 15:19:02 PercentComplete = 1 BarID = 501 Bar Time = 11-12-2018 15:19:00 Last Chart Bar = 11-12-2018 15:19:00
Current time = 11-12-2018 15:19:03 PercentComplete = 1 BarID = 501 Bar Time = 11-12-2018 15:19:00 Last Chart Bar = 11-12-2018 15:19:00
The printout shows 2 things:
1. After PercentComplete is set to 1.0, an update of the bar has been performed several times (see BarID)
2. Update of the bar is taking place during the time of the next bar (see Current time in comparision to the ongoing bar time)
Could you please clarify if such behavior is correct.
Thank you very much in advance
GmA
Comment