• 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 tcfcigvo, Yesterday, 11:39 PM
    0 responses
    6 views
    0 likes
    Last Post tcfcigvo  
    Started by BobbyWan, Yesterday, 09:15 PM
    0 responses
    9 views
    0 likes
    Last Post BobbyWan  
    Started by trader14, Yesterday, 08:23 PM
    0 responses
    4 views
    0 likes
    Last Post trader14  
    Started by ares5918, Yesterday, 02:37 PM
    2 responses
    18 views
    0 likes
    Last Post ares5918  
    Started by RTR1701, 11-15-2016, 11:38 AM
    22 responses
    1,272 views
    0 likes
    Last Post afcmaff
    by afcmaff
     
    Working...
    X