Thank you for all the suggestions.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
OnBarUpdate not Being Called in an Indicator
Collapse
X
-
I've followed NinjaSript best practices with regard to OnRender(). The method is kept lean when it comes to calculations.
That's the conclusion that I have come to. I've commented out pretty much every line of code, except OnBarUpdate, and still OnBarUpdate() is not called.Something else you could try is creating a new indicator with a working print in OnBarUpdate(). You could then slowly re-introduce parts of your script into the new indicator and reload the indicator to ensure that the OnBarUpdate print is still showing.
Thank you for all the suggestions.
-
Alright - I misunderstood. I thought you were hosting it in another indicator or strategy. You can disregard my earlier suggestion which was specific to that scenario.Originally posted by FatCanary View PostMy indicator is not trying to access any public property. It is a standalone indicator and is not hosted nor is it hosting anything.
Comment
-
Apologies - I misunderstood his earlier description and thought his indicator was hosted (and he had said he was only using OnRender leading me to think he had no plots) but now I see after his clarifications that I was barking up the wrong tree here as his indicator is not hosted. Sorry for any confusion I may have created by assuming incorrectly that his scenario was hosted.Originally posted by NinjaTrader_Emily View PostBruce, your input is appreciated, although I would like to clarify that OnBarUpdate() is called whenever a bar is updated based on the Calculate property.
- Likes 1
Comment
-
FatCanary, just a few suggestions, some or all of which you may have tried, or which may be irrelevant:- Check trace and log files for any "unexpected" entries
- Use try/catch around various areas of frequently invoked code -- it would be useful to use that in OnStateChange, and possibly even OnRender, as well as your own specific methods
- Add more Prints to try to follow the execution path using NinjaScript code, rather than break points ... just "because" -- even go so far as to add a Print at the start of every method or major decision points in methods
- If using VS, stick to the NinjaScript Editor, at least temporarily, just by way of encapsulating all activity to within the platform as a means of eliminating any potential interplay with VS
- Comment out all but the simplest areas of code and see what happens -- then re-introduce areas slowly to see what happens each time
Hope those are useful suggestions.
Thanks.
Comment
-
jeronymite Thank you for the tips.
I actually find the whole thing fascinating, and educational.It's tedious, and it may be something in your code, or it may be external to your code, but keep on keeping on.
What I have found now is that with very few lines of code (just enough to get the indicator to load and print to the output window), OnBarUpdate() is called.
However, as soon as I remove the indicator and reload it, OnBarUpdate() is no longer called.
Comment
-
-
Is there any chance that setting 'IsOverlay' to true would cause OnBarUpdate() to not be called?
Edit:
Or could it be IsDataSeriesRequired needs to be true?
https://ninjatrader.com/support/help...esrequired.htmNote: When set to false, methods and properties which are dependent on Bars will NOT be used. This means you will not receive any calls to OnBarUpdate() or be able to access historical bar prices.Last edited by FatCanary; 03-24-2023, 06:46 AM.
Comment
-
-
Hello FatCanary,
Thank you for the update.
I am glad to hear you figured it out; I apologize for the slight rabbit hole though I am glad you figured out which part of your script was causing this behavior. Sometimes finding the cause of unexpected behavior is like finding a needle in a haystack until you find an approach to narrow down the behavior and hone in on the cause.
IsDataSeriesRequired has a default value of true and it is not part of the NinjaScript Wizard's default properties screen, so typically it is only set to false with intent. It does not come up in support cases very often, but with that said I have added it to my notes in hopes to catch it more quickly in the future if other users write in with similar behavior. I appreciate your patience with me and the other folks who attempted to assist you in this thread!
I am curious; do you recall why you had IsDataSeriesRequired set to false in your script? This may also help me to better understand future support requests and forum posts where this may come up with unintended consequences.
Thank you again for your time and patience.
Comment
-
Hi Emily
No worries. I appreciate all the support that I received on this thread.
I've not used the NinjaScript Wizard in years, and couldn't even remember how to use it, but it did assist in narrowing down the cause of my problem. Also comparing to my other indicators helped.
Unfortunately not. I've been developing this indicator for a month or two, and cannot remember what possessed me to set IsDataSeriesRequired to false.I am curious; do you recall why you had IsDataSeriesRequired set to false in your script?
I suspect it was because the indicator does not use the values of any bars.
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
563 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
329 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
547 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment