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 Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    30 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    943 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    9 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by rocketman7, Today, 01:00 AM
    0 responses
    7 views
    0 likes
    Last Post rocketman7  
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    28 views
    0 likes
    Last Post wzgy0920  
    Working...
    X