I am curious what mechanism is required for Update() to not call OnBarUpdate per the documentation "If the values are already up to date, the Update() method will not be run".
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
OnBarUpdate() and Update()
Collapse
X
-
OnBarUpdate() and Update()
I am creating an indicator which has methods/properties for querying to be used by other strategies/indicators. Following patterns of other indicators and the documentation referenced here https://ninjatrader.com/support/helpGuides/nt8/en-us/ I call Update in these properties/methods. I noticed that OnBarUpdate is being called redundantly.
I am curious what mechanism is required for Update() to not call OnBarUpdate per the documentation "If the values are already up to date, the Update() method will not be run".Tags: None
-
Hello ntbone,
You have linked the landing page of the help guide.
Are you referring to the Update() method linked below?
Update() triggers OnBarUpdate().
If you have a property that is not a series, then this property should trigger OnBarUpdate() to run before being returned.Chelsea B.NinjaTrader Customer Service
-
Yes, I am referring to Update. It explicitly mentions "If the values are already up to date, the Update() method will not be run". I have found though that Update() seems to trigger OnBarUpdate() regardless of whether its already been run once for a given tick etc... when called from another indicator. I am not sure what that sentence of the documentation is referring to.
Comment
-
Hello ntbone,
How do you know OnBarUpdate() is triggering more than once?
I've tested printing a counter in OnBarUpdate() from a hosted script property that calls update that is pulled to a host script.
I'm only seeing OnBarUpdate() print once.
(edit) added CurrentBar as per ntbone suggestion, ..because of course CurrentBar..)Attached FilesLast edited by NinjaTrader_ChelseaB; 07-16-2019, 07:06 AM.Chelsea B.NinjaTrader Customer Service
Comment
-
I put print statements in the host script's OnBarUpdate at the beginning and the end. Then I call properties on the hosted script (anything that calls Update()). I then put print statements also in the hosted script OnBarUpdate. I will see that the hosted script OnBarUpdate will have multiple calls to OnBarUpdate nested inside the print statements of the host script. I was also using on each tick for the host script.
Comment
-
Hello ntbone,
If you add multiple prints you will see multiple prints.
Without modifying the test script I have provided you are you seeing there are multiple calls to OnBarUpdate for the same bar?
With Calculate.OnEachTick, each bar will update multiple times.Chelsea B.NinjaTrader Customer Service
Comment
-
The print output I get looks approximately as follows
Host OnBarUpdate startedCall method of hosted script that calls Update -> Hosted OnBarUpdate calledHost OnBarUpdate ended
Call different method of hosted script that calls Update -> Hosted OnBarUpdate called
If Update was doing as described in the documentation, "If the values are already up to date, the Update() method will not be run", the second call to Update would not be triggering OnBarUpdate. In this case I have not added multiple print statements to Hosted OnBarUpdate. OnBarUpdate is being called multiple times. I have also confirmed this with break points.
I also understand that Calculate.OnEachTick will result in each bar getting updated multiple times, however, the hosted script shouldn't see more updates than the host script that is triggering its OnBarUpdate via Update() method.
Comment
-
Hello ntbone,
On my end using my test script I am getting one print per bar update.
I would like to schedule a call with you so that you may demonstrate using the test script I have provided you with no modifications that OnBarUpdate() is triggering multiple prints for the same bar and that the output you are experiencing is different than the output I am experiencing when using the exact same test script with no modifications.
I will not be able to assist with using visual studio and break points to test this.
Please send an email to platformsupport [at] ninjatrader [dot] com. In the email please include a link to this forum thread.
Chelsea B.NinjaTrader Customer Service
Comment
-
Hi Chelsea
unsure if this is the right place to place this request for help converting an indi from 7>8,
i've started to build the indi but need to add the onbarupdate code, i've looked and looked at the info sent by the support team, no idea where to start, here is the files and what i want it to look like and do, hope you can help as i'd really like to learn to modify and start learning how to do it myself,
here is what i was asked to do, by support:
You basically would need to copy the code from the NT7 OnBarUpdate() method and paste it into the NT8 OnBarUpdate(), however once pasted you would need to convert the NT7 code to the equivalent NT8 code. To do that, please use the NT8 code breaking section of the help guide that will show the NT7 method/property and what the NT8 method/property
sounds simple enough ~ once i opened the help topic page it lists 2 pages of method properties, none of which seemed to relate to "On Bar Update" from what i could see
it may as well be written in Chinese, useless to a non coder, so if i am going to get help, i need to know what section of the code needs to be copied and what part of the method properties section needs changing, or a link showing an example of, which i'm sure there are plenty
regards Angelo
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by wzgy0920, 04-20-2024, 06:09 PM
|
2 responses
27 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:43 PM
|
||
Started by wzgy0920, 02-22-2024, 01:11 AM
|
5 responses
32 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:33 PM
|
||
Started by wzgy0920, 04-23-2024, 09:53 PM
|
2 responses
49 views
0 likes
|
Last Post
by wzgy0920
Yesterday, 10:29 PM
|
||
Started by Kensonprib, 04-28-2021, 10:11 AM
|
5 responses
193 views
0 likes
|
Last Post
by Hasadafa
Yesterday, 10:19 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
11 responses
3,235 views
0 likes
|
Last Post Yesterday, 08:07 PM |
Comment