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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      599 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      344 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      558 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      557 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X