Announcement

Collapse
No announcement yet.

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
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    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.

          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          574 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X