Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Incorrect bars are being reported in OnBarUpdate()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Incorrect bars are being reported in OnBarUpdate()

    Hi,
    I am working with 1 tick secondary dataseries and i am getting incorrect bars reported. A trimmed down version of my indicator:
    Code:
    protected override void OnStateChange()
    {
        if (State == State.SetDefaults)
        {
            IsChartOnly                 = true;
            IsOverlay                   = true;
            DisplayInDataBox            = false;
            DrawOnPricePanel            = true;
            IsSuspendedWhileInactive    = false;
            Calculate                   = Calculate.OnEachTick;
            MaximumBarsLookBack         = MaximumBarsLookBack.TwoHundredFiftySix;
            BarsRequiredToPlot          = 0;
        }
        else if (State == State.Configure)
        {
            // Other modes not supported.
            Calculate = Calculate.OnEachTick;
            AddDataSeries(Instrument.FullName, BarsPeriodType.Tick, 1, MarketDataType.Last);
        }
    }
    #endregion
    
    protected override void OnBarUpdate()
    {
        if (CurrentBars[0] < BarsRequiredToPlot || CurrentBars[1] < BarsRequiredToPlot)
            return;
    
        var barTime = Time[0].ToString("yyyy-MM-dd HH:mm:ss.ffffff");
        Print((BarsInProgress == 0 ? "BARS" : "TICK") + $" BARS={CurrentBars[0]} TICK={CurrentBars[1]} TIME={barTime} CLOSE={Close[0]} VOL={Volume[0]}");
    }​
    Below you can see a screenshot of printed values. I marked last correct ticks in yellow. After that, as you can see time rewinds a little for ticks and closing price is bogus. Further down there is a sharp jump down in time from 16:16:59 to :16:00:00. Historical tick data window shows no such values. This happens when i reload a chart with my indicator in paused simulator, on MNQ 12-24.

    Click image for larger version  Name:	image.png Views:	2 Size:	323.5 KB ID:	1326256

    If this is a bug, it seems to be quite a major one. Or maybe this is my fault somehow? Does anyone encounter anything like this? Is there any known workaround maybe?
    Last edited by rokups; 12-01-2024, 05:54 AM.

    #2
    Hello rokups,

    Use null for the instrument as using variables (dynamic) with AddDataSeries() is not supported.

    Who are you connected to for data?

    Please also print the State property in the print.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Unfortunately i am no longer able to reproduce the issue.

      I since switched to instrumentless AddDataSeries(), though i can not say this was the remedy.
      I am using data from the standard "Simulation" connection, this specific issue was observed during playback using historical tick data (not market replay).

      If i ever encounter this issue again i will get back to this thread with more information.

      Thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      55 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      37 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      17 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      19 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      49 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X