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

bar out of valid range

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

    bar out of valid range

    I have an indicator that uses DrawArrowDown. It works fine most of the time but occasionally runs into an error:
    DrawArrowDown: bar out of valid range 0 through -1 was 0.
    If I close the chart and create a new chart it usually goes away.
    Any ideas on how I could handle this?
    I have put all the suggested:
    Code:
    if (CurrentBar < 1) return;
    type checks but this doesn't seem to be the problem. The valid bar range from the error says 0 through -1 and I am always using 0 (current bar).

    Thanks

    #2
    trtrav, it would still look to me like a CurrentBars related issue - what exact call are you using for DrawArrowDown? Is this a MultiSeries script you're using it with?

    Thanks,
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Yes, it is a multiseries. It is an indicator, I add additional series in initialize using:

      Code:
       Add(PeriodType.Tick, 725);
      Then in OnBarUpdate()

      Code:
      if (BarsInProgress==1)
      {	
      	if (CurrentBar < 100) //tried different numbers, but error still happens at some point.
      		return;
      			if (FirstTickOfBar)
      			{
      //more code
      
      DrawArrowDown("short" + CurrentBar,true,0,Bollinger(Median,bbStandardDeviation, bbPeriod).Upper[0] + .4, Color.DarkSalmon);
      
      //more code
      }
      }

      Comment


        #4
        Originally posted by trtrav View Post
        Yes, it is a multiseries. It is an indicator, I add additional series in initialize using:

        Code:
         Add(PeriodType.Tick, 725);
        Then in OnBarUpdate()

        Code:
        if (BarsInProgress==1)
        {	
        	if (CurrentBar < 100) //tried different numbers, but error still happens at some point.
        		return;
        			if (FirstTickOfBar)
        			{
        //more code
        
        DrawArrowDown("short" + CurrentBar,true,0,Bollinger(Median,bbStandardDeviation, bbPeriod).Upper[0] + .4, Color.DarkSalmon);
        
        //more code
        }
        }
        Without seeing the rest of your code, it is hard to tell, but you probably also need a bars filter for BarsInProgress == 0, your primary price DataSeries.

        Comment


          #5
          Please try adding a CurrentBars check for all series involved in the script :

          BertrandNinjaTrader Customer Service

          Comment


            #6
            Yes, I already have the check in both places. The DrawArrowDown is only used in the 2nd series and that is where the error is thrown and logged in the error log. Understand that I can't even duplicate this at this point. It just happens sometimes and then I close the chart and start again. Sometimes it gets stuck doing it and others it immediately (after creating a new chart) goes away.

            Thanks

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by cmtjoancolmenero, Yesterday, 03:58 PM
            11 responses
            38 views
            0 likes
            Last Post cmtjoancolmenero  
            Started by FrazMann, Today, 11:21 AM
            0 responses
            3 views
            0 likes
            Last Post FrazMann  
            Started by geddyisodin, Yesterday, 05:20 AM
            8 responses
            52 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by DayTradingDEMON, Today, 09:28 AM
            4 responses
            25 views
            0 likes
            Last Post DayTradingDEMON  
            Started by George21, Today, 10:07 AM
            1 response
            22 views
            0 likes
            Last Post NinjaTrader_ChristopherJ  
            Working...
            X