• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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());
    DierkNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Bouzayen, Today, 08:31 PM
    0 responses
    8 views
    0 likes
    Last Post Bouzayen  
    Started by IanC28, 03-27-2020, 10:20 AM
    6 responses
    28 views
    0 likes
    Last Post jim1234
    by jim1234
     
    Started by aramtrader, Yesterday, 03:05 PM
    7 responses
    38 views
    0 likes
    Last Post woodie1
    by woodie1
     
    Started by renehtx, Today, 03:51 PM
    2 responses
    16 views
    0 likes
    Last Post renehtx
    by renehtx
     
    Started by eidog2020, Today, 03:31 PM
    0 responses
    7 views
    0 likes
    Last Post eidog2020  
    Working...
    X