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

in the Ninja Swing indicator....what does Update() do??

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

    in the Ninja Swing indicator....what does Update() do??

    is it a Ninja method?

    (this may be a dumb question...but, well..)

    #2
    Hello llanqui,

    Thanks for your post.

    The Update() method is a NinjaScript method that forces OnBarUpdate() to be called for all data series so that indicator values are updated to the current bar index.

    From the help guide: "When indicators are embedded (called) within a NinjaScript strategy, they are optimized to calculate only when they are called upon in a historical backtest. Since the NinjaTrader indicator model is very flexible, it is possible to create public properties on a custom indicator that return values of internal user defined variables. If these properties require that the OnBarUpdate() method is called before returning a value, include a call to this Update() method in the property getter."

    See this help guide page for further information about Update(): https://ninjatrader.com/support/help...nt8/update.htm
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      yes I found it...thank you....was not in the Help / Search

      Comment


        #4
        Hey Brandon - can Update() be used to retrieve the current value of an embedded indicator in the middle of a bar without needing to run the parent script/indicator as OnPriceChange or OnEachTick, assuming I want to use some property of the indicator as a condition?

        Take, for example, the VolumeCounter indicator, which counts down, by percent, the volume remaining before a new volume bar will be created. Would Update allow me to run an indicator using OnBarClose and still be able to reference the data necessary to make the following condition work?

        Code:
        if (updateTriggerCondition)
        {
            Update();
            if (volCounter.pctLeft < 10)
            {
                Print("Volume Bar About to Close!");
            }
        }
        The key here is that I get the performance benefit of using OnBarClose and only need to run the embedded indicator code when updateTriggerCondition is true. As an added note, if Update() happens not to be viable for this use-case, is there another means of accessing snapshot data from an embedded indicator property without needing to use the more granular OnBarUpdate calculation frequency?

        Comment


          #5
          Hello lunardiplomacy,

          Thanks for your notes.

          When a script is running with the Calculate mode Calculate.OnBarClose, all OnBarUpdate() logic in the script will only be processed at the close of a bar. Logic will not be processed intrabar. This means that if you are calling .Update() on an indicator in OnBarUpdate() the logic will only fire at the close of a bar.

          To have logic process intrabar instead of only at the close of a bar, you would have to use Calculate.OnPriceChange or Calculate.OnEachTick.

          If you need to separate logic between Calculate.OnBarClose and Calculate.OnEachTick/OnPriceChange, you could use IsFirstTickOfBar. Below is a reference sample demonstrating this concept.

          Brandon H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Haiasi, 04-25-2024, 06:53 PM
          2 responses
          17 views
          0 likes
          Last Post Massinisa  
          Started by Creamers, Today, 05:32 AM
          0 responses
          5 views
          0 likes
          Last Post Creamers  
          Started by Segwin, 05-07-2018, 02:15 PM
          12 responses
          1,786 views
          0 likes
          Last Post Leafcutter  
          Started by poplagelu, Today, 05:00 AM
          0 responses
          3 views
          0 likes
          Last Post poplagelu  
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,407 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Working...
          X