Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnBarUpdate not Being Called in an Indicator

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

    #16
    I've followed NinjaSript best practices with regard to OnRender(). The method is kept lean when it comes to calculations.

    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.
    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.

    Thank you for all the suggestions.

    Comment


      #17
      Originally posted by FatCanary View Post
      My indicator is not trying to access any public property. It is a standalone indicator and is not hosted nor is it hosting anything.
      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.
      Bruce DeVault
      QuantKey Trading Vendor Services
      NinjaTrader Ecosystem Vendor - QuantKey

      Comment


        #18
        Originally posted by NinjaTrader_Emily View Post
        Bruce, your input is appreciated, although I would like to clarify that OnBarUpdate() is called whenever a bar is updated based on the Calculate property.
        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.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #19
          Alright - I misunderstood. I thought you were hosting it in another indicator or strategy.
          No problem. It's likely me not explaining myself very well.
          Your input was appreciated.

          Comment


            #20
            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
            It's tedious, and it may be something in your code, or it may be external to your code, but keep on keeping on.

            Hope those are useful suggestions.

            Thanks.
            Multi-Dimensional Managed Trading
            jeronymite
            NinjaTrader Ecosystem Vendor - Mizpah Software

            Comment


              #21
              jeronymite Thank you for the tips.


              It's tedious, and it may be something in your code, or it may be external to your code, but keep on keeping on.
              I actually find the whole thing fascinating, and educational.

              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


                #22
                Just wondering now whether there could be an issue with the workspace xml file.

                Edit:
                Maybe not. I can reload an NT generated script, and OnBarUpdate() is called.
                I'm guessing it's my code. Just need to find where...
                Last edited by FatCanary; 03-24-2023, 06:06 AM.

                Comment


                  #23
                  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?
                  Note: 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.
                  https://ninjatrader.com/support/help...esrequired.htm
                  Last edited by FatCanary; 03-24-2023, 06:46 AM.

                  Comment


                    #24
                    Solved:
                    IsDataSeriesRequired needs to be true.

                    This is why I originally asked the question. I didn't want to go down the rabbit hole looking for an issue in my code when the problem could be something fundemental that I had missed.
                    Last edited by FatCanary; 03-24-2023, 07:00 AM.

                    Comment


                      #25
                      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


                        #26
                        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.

                        I am curious; do you recall why you had IsDataSeriesRequired set to false in your script?
                        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 suspect it was because the indicator does not use the values of any bars.
                        Last edited by FatCanary; 03-24-2023, 10:00 AM. Reason: Typo

                        Comment


                          #27
                          Hi FatCanary,

                          Thanks for the feedback!

                          Regardless, I am glad this has been resolved. Please don't hesitate to reach out with any other questions or concerns in the future.

                          Have a great day and thank you for using NinjaTrader.

                          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 Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          329 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          101 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          547 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          547 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X