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 DannyP96, 05-18-2026, 02:38 PM
    1 response
    84 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    143 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    83 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    256 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    334 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X