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

The evaluation order of indicators

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

    The evaluation order of indicators

    I have indicators A and B, where A will reference B.

    How to enforce NT to evaluate B before A? (A needs B's value)

    David

    #2
    Hi David, you can force an update of the indicators OnBarUpdate() with the Update() method - http://www.ninjatrader-support.com/H...V6/Update.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      One more question: are those built-in indicators (like EMA,SMA) always evaluated before the custom ones? Or do we need to use Update() to enforce their updates?

      Thanks.

      David

      Comment


        #4
        The method doesn't seem to work.

        I have already put an Update() in B, but A still can not get the update-to-date value from B.

        Note that the document only states that the method works for "strategy".

        Quoted from the document:
        "When indicators are embedded (called) within a NinjaScript strategy,...."

        David

        Comment


          #5
          David,

          Since you are discussing a very specific concept it would be better if you posted very simple code and we can evaluate it in theory for you. Thank you.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            For example, in @Bollinger.cs (attached the code), how to make sure SMA(Period)[0] has the most update-to-date value? There is a possibility that SMA(Period)'s OnBarUpdate() is executed after the Bollinger's OnBarUpdate(). In such a case, Bollinger's OnBarUpdate() will access SMA(Period)'s [0], but that [0] may not has been set (so a test of ContainsValue(0) will give FALSE). I can explain more if the above question is unclear.


            protected override void OnBarUpdate()
            {
            Upper.Set(SMA(Period)[0] + NumStdDev * StdDev(Period)[0]);
            Middle.Set(SMA(Period)[0]);
            Lower.Set(SMA(Period)[0] - NumStdDev * StdDev(Period)[0]);
            }

            Comment


              #7
              David,

              It should always be the most up-to-date value. I am not sure how you are evaluating this scenario exactly. If you still feel it is not you can try calling Update() to force an update.
              Josh P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Waxavi, Today, 02:10 AM
              1 response
              16 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by Kaledus, Today, 01:29 PM
              5 responses
              13 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Waxavi, Today, 02:00 AM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by alifarahani, Today, 09:40 AM
              5 responses
              23 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by gentlebenthebear, Today, 01:30 AM
              3 responses
              17 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X