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!
See more
See less

Partner 728x90

Collapse

Strange error that I cant replicate in others PC

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

    Strange error that I cant replicate in others PC

    I created an indicator that works in 2 PCs but launch this log error in 1 windows 10 pc:

    2020-08-18 06:23:42:610|3|4|Indicator 'MyTest' Error on calling 'OnBarUpdate' method on bar 42639: 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.


    The indicator works in real time in the last bar.
    Trying to above the historical. This is the first line of 'OnBarUpdate' method:

    if(CurrentBar < Count-2 ) return;


    Any idea whats is happening?
    Thank you


    #2
    Hello ninjo,

    Thank you for your post.

    This sounds like potentially an issue of data being different on one machine than another and possibly causing values to be returned that cause an issue in the indicator.

    Does the PC in question use the same data provider as the two it does work correctly on?

    I would suggest adding prints to the script to help you narrow down the source of the error.

    This forum post goes into great detail on how to use prints to help figure out where issues may stem from — this should get you going in the correct direction.

    https://ninjatrader.com/support/foru...ns-not-working

    I'd print out the value of any variables and look to see at what point they stop printing and what the values were at that point.

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      CQG and Continuum, but is not the problem because i am testing in different Pcs with differents connections.

      Any suggestion? Thank you.

      Comment


        #4
        I deleted this line:

        if(CurrentBar < Count-2 ) return;

        And all works in the 2 Pcs but in the error Pc this is the log....


        2020-08-18 08:24:24:061|3|4|Indicator 'My Test': Error on calling 'OnBarUpdate' method on bar 0: 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.


        ¿?

        Comment


          #5
          Hello ninjo,

          Thank you for your reply.

          Different connections may have different data. I would ensure all the PCs you are testing with are getting data from the same source - so if you're testing on one using Continuum, please also use a Continuum connection to test on all of them.

          We would suggest, as in my previous post, that you add prints to the indicator to determine what precise line of code is throwing the error. I've quoted that section of my previous post below:

          I would suggest adding prints to the script to help you narrow down the source of the error.

          This forum post goes into great detail on how to use prints to help figure out where issues may stem from — this should get you going in the correct direction.

          https://ninjatrader.com/support/foru...ns-not-working

          I'd print out the value of any variables and look to see at what point they stop printing and what the values were at that point.
          Specifically to help narrow down where the error occurs, something I do in my debugging sometimes is put a print between most lines of code that are numbered. Then, when the error occurs, note the last number that printed, and then you can focus on the code that comes immediately after that print by printing the values of any variables used or calculations made.

          Please let us know if we may be of further assistance to you.
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            Hi Kate, thank you very much.

            I create "Prints" in each significant line of the code and I find the error in this line:


            DateTimeNow.AddHours(Hours*-1)


            Why is launching an error in one PC?
            The error PC is in USA, the correct PCs are in Europe... do you think it has something to do with it?

            EDIT:
            Works if the Windows DateTime region is Spanish (Spain) and not work if is English(***) ¿?¿?

            NOTE:
            I compiled the script in an Spanish Pc Windows. (Maybe works if I compile with USA dateFormat? )
            Last edited by ninjo; 08-18-2020, 11:16 AM.

            Comment


              #7
              Hello ninjo,

              Thank you for your reply.

              It does sound like you might be hitting a problem with date formatting. I would try with a US date format, yes.

              Thanks in advance; I look forward to assisting you further.
              Kate W.NinjaTrader Customer Service

              Comment


                #8
                Thank you Kate.

                I solved the problem with USA Ninjatrader platforms.

                The problem is about the USA date time format, in this case I need to change to an English (United Kingdom) region date format and 24 H (without zero) time format

                I thought that Ninjatrader 8 platform would control it...

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by llanqui, Yesterday, 10:29 AM
                3 responses
                20 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by cshox, Today, 11:11 AM
                1 response
                3 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by Seneca, 08-25-2020, 08:31 AM
                4 responses
                5,952 views
                0 likes
                Last Post Tin34
                by Tin34
                 
                Started by TAJTrades, Today, 11:03 AM
                0 responses
                3 views
                0 likes
                Last Post TAJTrades  
                Started by wuannetraam, Today, 02:40 AM
                3 responses
                25 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Working...
                X