Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on calling 'EventHandlerBarsUpdate' method:

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

    Error on calling 'EventHandlerBarsUpdate' method:

    Hello All!

    Sometimes I see the next message in the Log:

    Strategy 'TTPTrendBOTaug29': Error on calling 'EventHandlerBarsUpdate' method: Object reference not set to an instance of an object.
    Indicator 'EMA': Error on calling 'OnBarUpdate' method on bar 5174: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

    After that NT8 stoping my strategy.

    It's random error and I don't see this massege each time when strategy is working.. Sometimes I see this eror shortly after start of the strategy, sometimes after a few hours, sometimes on the some days - I don't see it...

    I added EMA in the State.DataLoaded.


    #2
    I mean that I added EMA on the chart in the State.DataLoaded.

    In OnBarUpdate I use:

    if (CurrentBar < BarsRequiredToTrade) return;
    Last edited by vitaly_p; 09-05-2023, 08:14 AM.

    Comment


      #3
      Hello vitaly_p,

      Thank you for your note.

      The following pages in the help guide explain potential causes for errors such as "Object reference not set to an instance of an object" as well as "You are accessing an index with a value that is invalid since it is out-of-range"By using the tips suggested on those pages, you should be able to prevent these types of errors at runtime. You can add null references prior to accessing an object's value and also add checks to not attempt to access a series unless you are sure that the index in the series is valid and has a value assigned to it.

      Please let us know if we may be of further assistance.

      Comment


        #4
        Hello Emily

        Thank you for your answer.
        I know about it, it's not first my stsrategy.
        It helped me in the situation when strategy was stoped after start... but in the current situation it's random error.
        And number of bars when called errors are to big... 5000, 11000 e t.c.




        And I don't understand error : Error on calling 'EventHandlerBarsUpdate' method..
        Whai is it?



        Comment


          #5
          Hello vitaly_p,

          Thank you for your reply.

          You mentioned that you added the EMA when State == State.DataLoaded. Are you adding it via AddChartIndicator() or another way? What is the period you use for the EMA and what do you have BarsRequiredToTrade set to?

          The strategy is the parent script and it is hosting the EMA indicator. I believe EventHandlerBarsUpdate is part of how OnBarUpdate() gets synced up between both scripts. As mentioned in the help guide, "Hosted indicators will need to be accessed by the hosting script to ensure OnBarUpdate functionality. This can be done by: 1) Calling Update on the hosted indicator within the host script, 2) Including a plot in the hosted indicator and accessing the plot in the host script, 3) Including a plot in the hosted indicator and adding the indicator to the chart with AddChartIndicator (strategies only)​"

          So I may accurately assist you, please also answer the following questions:
          • What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.?.?.?)
          • Who are you connected to? This is displayed in green in the lower-left corner of the Control Center window.
          • Who is your broker?
          • What instrument symbol (and expiry if applicable) have you selected? For example, ES 03-22, AAPL, EURUSD, etc.
          • What interval is selected? For example, 5 minute, 1 day, 2000 volume, 4 Renko, etc.
          • Do you receive an error on the screen? Are there errors on the Log tab of the Control Center (other than the two errors you already mentioned)? If so, what do these errors report?
          I look forward to your reply.

          Comment


            #6
            Yes, I added via AddChartIndicator() .

            * Version: 8.1.1.7. 64bit;
            * Rithmic;
            * I use APEX account;
            * MNQ 09-23;
            * 1min, 3 min, 15 sec;
            * without errors on the screen, just on the Log

            Comment


              #7
              Originally posted by vitaly_p View Post
              Yes, I added via AddChartIndicator() .

              * Version: 8.1.1.7. 64bit;
              * Rithmic;
              * I use APEX account;
              * MNQ 09-23;
              * 1min, 3 min, 15 sec;
              * without errors on the screen, just on the Log
              Thank you for your reply.

              I would like to review your diagnostic files for additional information. Please open a support email containing your log and trace files. You can do this by going to the Control Center-> Help-> Email Support. Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default. Please also include "ATTN Emily C" in the subject line and body of the email along with a link to this forum thread in the body of the email prior to clicking Send.

              I appreciate your patience and look forward to investigating this further.​

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              67 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              142 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              76 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              47 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              51 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X