Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why I get wrong index?

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

    Why I get wrong index?

    I get this code:
    private Series<double> OpenBuffer;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Введите описание новой пользовательской Индикатор здесь.";
    Name = "МойПользовательскийIndicator";
    Calculate = Calculate.OnBarClose;
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    IsSuspendedWhileInactive = true;
    AddPlot(new Stroke(Brushes.DarkGray, DashStyleHelper.Dash, 1), PlotStyle.Line, "Main Value");
    }
    else if (State == State.Configure)
    {
    OpenBuffer = new Series<double>(this);
    }
    }

    protected override void OnBarUpdate()
    {
    //Добавьте логику пользовательского indicator здесь.
    OpenBuffer[0] = Values[0][0] = CurrentBar;
    }

    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    if (ChartControl == null)
    return;
    base.OnRender(chartControl, chartScale);
    try
    {
    for (int chartBarIndex = ChartBars.FromIndex; chartBarIndex <= ChartBars.ToIndex; chartBarIndex ++)
    Print (Values[0].GetValueAt(chartBarIndex) + " " +OpenBuffer.GetValueAt(chartBarIndex)+" " +chartBarIndex);
    }
    catch (Exception exc)
    {
    Print("OnRender failure chart: " + exc.ToString());
    }
    }
    }
    The indicator must print Value from start visible bar to end visible bar and 3 values must be iqual. But the real result is not iqual values. See Attachment. Why indicator get wrong index?
    Attached Files

    #2
    Hi, thanks for posting. Set the BarsRequiredToPlot = 0; in State.SetDefault to start plotting immediately when the data starts and these numbers should match up.

    Kind regards.

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hi, thanks for posting. Set the BarsRequiredToPlot = 0; in State.SetDefault to start plotting immediately when the data starts and these numbers should match up.
      Hello Dear Friend!
      Thank you for answer.

      // Store all series values instead of only the last 256 values
      MaximumBarsLookBack = MaximumBarsLookBack.Infinite;

      This is parameter need for draw full indexes.

      Thank you.
      Last edited by _Roman; 08-05-2022, 06:26 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      51 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      33 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      165 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      100 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      161 views
      2 likes
      Last Post CaptainJack  
      Working...
      X