Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,606 views
    0 likes
    Last Post aligator  
    Started by jaybedreamin, Today, 05:56 PM
    0 responses
    8 views
    0 likes
    Last Post jaybedreamin  
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    18 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    4 views
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    13 views
    0 likes
    Last Post Javierw.ok  
    Working...
    X