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

Value outside of range errors

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

    Value outside of range errors

    Okay, I wrote a multi instrument indicator (the source of which I can't share, sorry). One big problem I am experiencing is the dreaded 'value outside of range' issue, which ONLY happens when I scroll past the loaded data. Let's say I loaded six days worth of data and I scroll over beyond that (i.e. the seventh day, which should be empty of course), THEN the entire indicator panel (not the chart panel) goes blank and I'm getting this:

    ERROR: Error on setting indicator plot for indicator 'MultiInstrument'. Value outside of valid range.


    Now, I have done my homework and am checking for all instruments at the beginning of my OnBarUpdate() method:

    Code:
            try {
                    bool proceed = true;
                    if (Bars == null ||CurrentBar < 1) {
                        proceed = false;
                    }
                    for (int j = 1; j <= numSymbols ; j++) {
                        if (Opens[j].Count < Smooth + 1 || CurrentBars[j] < 1) { 
                            proceed = false;
                        }
                        if (Closes[j].Count < Smooth + 1 || CurrentBars[j] < 1) { 
                            proceed = false;
                        }
                        if (Volumes[j].Count < Smooth + 1 || CurrentBars[j] < 1) { 
                            proceed = false;
                        }
                    }
                    if (Close.Count < Smooth + 1 || CurrentBar < 1) {
                        proceed = false;
                    }
                        if (proceed) {
      
                        // do my business....
                    }
                } catch (Exception e) {
                    Print(Time[0]+ " Error!" + " " + e.ToString());
                    Log(Time[0]+ " Error!" + " " + e.ToString(), LogLevel.Error);
                }
    Now, I don't get any details in my print/log tail - even when I compile the indicator in debug mode.

    Is there any you guys can think of I may have missed? It's really annoying that I have to relaunch the indicator every time I accidentally scroll over too far.

    Any input would be appreciate?

    #2
    Hello,

    Thanks for the forum post.

    Did you override Plot() by any chance?


    I look forward to assisting you further.

    Comment


      #3
      No - did not override Plot() - never done that before. What else could cause this? Is there a way to produce a more detailed trace?

      Comment


        #4
        Hello,

        In this case I would not expect this. Would need you to send your code Unfortunately to support at ninjatrader dot com for me to look into this as without it I would only be shooting in the dark as to what would cause this. If needed please create a second indicator that has some of your proprietary indicator code stripped out so that it can just demonstrate the problem for me to look into this for you.

        Comment


          #5
          I've had problems like that in the past and they are a challenge to debug. I put in a lot of Print statements to narrow down where it fails and what the index values are at the time, and when I find the right section I'll put Prints between every statement. Usually there really is something out of range, but in a way that is really subtle.

          As I recall, when you scroll to the right, NT7 will call OnBarUpdate for any bars that become newly visible. I'm not sure what it would do in your case, if all the data is already on the screen, I wouldn't expect OnBarUpdate to be called at all. But Print statements in OnBarUpdate should tell you.

          Are you running with CalculateOnBarClose == false? Try changing the setting and see if it makes a difference.

          -Kevin

          Comment


            #6
            Thanks kdoren - really appreciate your insights. Yes, I am running it with CalculateOnBarClose = false. I may try to disable it to see if it makes any difference.

            Had tons of print statements - yes. Trouble is that they all look good and I don't seem to have an index problem anywhere. I'm checking for that right at the beginning of my onBarUpdate method.

            What was the problem on your end that caused it? Invalid index call or something else?

            Comment


              #7
              Fixed it!

              Yes, it was an index problem - I fixed it. Thanks!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by suroot, 04-10-2017, 02:18 AM
              5 responses
              3,021 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by Stanfillirenfro, Today, 07:23 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by cmtjoancolmenero, Yesterday, 03:58 PM
              2 responses
              22 views
              0 likes
              Last Post cmtjoancolmenero  
              Started by olisav57, Yesterday, 07:39 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by cocoescala, 10-12-2018, 11:02 PM
              7 responses
              944 views
              0 likes
              Last Post Jquiroz1975  
              Working...
              X