Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnRender problem

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

    OnRender problem



    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)

    // protected override void OnRender(ChartControl chartControl, ChartScale chartScale, ChartBars chartBars)
    {
    if (CurrentBar < 100) return;
    Draw.Line(this, "newLine" + CurrentBar, 5, Low[5], 3, Low[3], Brushes.Red);
    return;

    }

    Ninjascript output :

    Indicator 'OnRenderProblem': Error on calling 'OnRender' method on bar 550: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

    i don't understand it..why it give me error? the number of Bar is >5....
    Attached Files
    Last edited by turbofib; 07-25-2017, 04:26 AM.

    #2
    Hello turbofib,

    Thanks for opening the thread.

    OnRender() is not guaranteed to be in sync with OnBarUpdate() and barsAgo indexes may not be valid references. We have this noted in the OnRender() documentation here:
    5. Unlike market data events and strategy order related events, there is NO guarantee that the barsAgo indexer used for Series<T> objects are in sync with the current bars in progress. As a result, you should favor using an absolute index method to look up values (e.g., <series>.GetValueAt(), Bars.GetOpen(), etc)
    http://ninjatrader.com/support/helpG.../?onrender.htm

    You can reference GetValueAt() and GetLow() below:

    GetValueAt() - http://ninjatrader.com/support/helpG...getvalueat.htm

    GetLow() - http://ninjatrader.com/support/helpG...-us/getlow.htm

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    574 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    333 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    553 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X