Announcement

Collapse
No announcement yet.

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,

    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 :

          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 cmoran13, 04-16-2026, 01:02 PM
            0 responses
            42 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            25 views
            0 likes
            Last Post PaulMohn  
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            162 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            98 views
            1 like
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            157 views
            2 likes
            Last Post CaptainJack  
            Working...
            X