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 Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            579 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X