Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to access EMA value of a bar inside OnRender()?

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

    How to access EMA value of a bar inside OnRender()?

    Hi! I have a NT8 indicator which plots lines under a clicked bar. In the onRender method it gets the clicked bar index with:

    barIdx = ChartBars.GetBarIdxByX(chartControl, clickPixelX); <- This works already


    How do I get the EMA(10) value of this clicked bar?

    I have my EMA instancied correctly

    private ema EMA;

    else if (State == State.Historical)
    {
    ema= EMA(10);


    but when I call

    ema[barIdx] I get an out-of-bound exception.

    What am I doing wrong? Thanks!

    #2
    Hello Orion1504,

    Thank you for your inquiry.

    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. In this case, you could use GetValueAt():



    Please let us know if we may be of further assistance to you.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    66 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X