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 CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    232 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    149 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    161 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    243 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    198 views
    0 likes
    Last Post CarlTrading  
    Working...
    X