Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get indicator value synced for Strategy

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

    How to get indicator value synced for Strategy


    Hello Ninjatrader team,

    I have a strategy that uses two instruments to trade.
    One of the indicators uses data from both instruments to make its calculations.
    To specify to the indicator which is the second symbol to use, I followed the approach used in Correlation Indicator, this is declaring a string in its properties which is then used in the AddDataSeries() method inside the indicator, and so on...

    The thing is, this indicator is not getting updated before its value is called from the strategy's OnBarUpdate method
    How do I make sure this indicator is updated when both Bars Time are equal (in sync) and be able to use it inside the strategy

    Thanks in advance,
    Lis

    #2
    Hi Lis, thanks for posting. The Indicator can be forced to update by calling the Update() method on it. e.g.

    Code:
    private SMA MySMA; //initialize in DataLoaded, MySMA = SMA(BarsArray[1]);
    
    //OnBarUpdate:
    
    if(BarsInProgress == 0)
    {
        MySMA.Update();
    
       Print(MySMA[0]);
    }
    If this does not resolve, I will need a reduced example script to see the issue happening.

    Kind regards,
    -ChrisL

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    553 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    100 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    543 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    546 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X