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 natngk, 02-21-2019, 06:27 AM
      21 responses
      1,291 views
      1 like
      Last Post FMtrader  
      Started by richt3, Yesterday, 10:28 PM
      0 responses
      5 views
      0 likes
      Last Post richt3
      by richt3
       
      Started by Atychiphobia66, Yesterday, 10:22 PM
      0 responses
      7 views
      0 likes
      Last Post Atychiphobia66  
      Started by Scalper1969, Yesterday, 09:24 PM
      0 responses
      13 views
      0 likes
      Last Post Scalper1969  
      Started by RISKYBUSINEZZ, 12-12-2023, 05:11 PM
      3 responses
      127 views
      0 likes
      Last Post judysamnt7  
      Working...
      X