Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

How to access price data more than 20 barsAgo

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

    How to access price data more than 20 barsAgo

    I want to compare the EMA(200)[0] to EMA(200)[40] or higher but when I assign the latter to a variable it comes up null - the most I can get is 20 bars ago.

    Is there a way to increase the maximum number of bars one can reference?

    Code:
    protected override void OnBarUpdate()
    
    {
    
    Print(EMA(200)[20].ToString());
    
    }
    KD

    #2
    imported post

    There is no limitation on # of bars ago you can reference. You only need to make sure your CurrentBar index is greater than the lookback value, like

    Code:
    if (CurrentBar > 40)
      Print(EMA(200)[40].ToString());

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by arvidvanstaey, Today, 02:19 PM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Started by mmckinnm, Today, 01:34 PM
    3 responses
    5 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by f.saeidi, Today, 01:32 PM
    2 responses
    6 views
    0 likes
    Last Post f.saeidi  
    Started by alifarahani, 04-19-2024, 09:40 AM
    9 responses
    55 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Conceptzx, 10-11-2022, 06:38 AM
    3 responses
    60 views
    0 likes
    Last Post NinjaTrader_SeanH  
    Working...
    X