• 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

  • lewdfinger
    started a topic How to access price data more than 20 barsAgo

    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

  • NinjaTrader_Dierk
    replied
    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());

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by Jschmelz, Today, 04:45 PM
1 response
7 views
0 likes
Last Post NinjaTrader_Marco  
Started by sisenberg, Today, 08:06 PM
1 response
8 views
0 likes
Last Post sisenberg  
Started by priceisking, Today, 07:44 PM
0 responses
5 views
0 likes
Last Post priceisking  
Started by saltminer, Today, 06:06 PM
0 responses
5 views
0 likes
Last Post saltminer  
Started by KennyK, Today, 05:25 PM
0 responses
7 views
0 likes
Last Post KennyK
by KennyK
 
Working...
X