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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    153 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    89 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    133 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    128 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    107 views
    0 likes
    Last Post CarlTrading  
    Working...
    X