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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    30 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    17 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    9 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    16 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    19 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X