(this may be a dumb question...but, well..)
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!
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
NinjaTrader
in the Ninja Swing indicator....what does Update() do??
Collapse
X
-
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.htmBrandon H.NinjaTrader Customer Service
-
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!"); } }
Comment
-
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
by Massinisa
Today, 05:32 AM
|
||
Started by Creamers, Today, 05:32 AM
|
0 responses
5 views
0 likes
|
Last Post
by Creamers
Today, 05:32 AM
|
||
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
12 responses
1,786 views
0 likes
|
Last Post
by Leafcutter
Today, 05:30 AM
|
||
Started by poplagelu, Today, 05:00 AM
|
0 responses
3 views
0 likes
|
Last Post
by poplagelu
Today, 05:00 AM
|
||
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,407 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
Comment