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 cmoran13, 04-16-2026, 01:02 PM
    0 responses
    43 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    25 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    163 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    98 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    158 views
    2 likes
    Last Post CaptainJack  
    Working...
    X