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 andrewtrades, Today, 04:57 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by chbruno, Today, 04:10 PM
            0 responses
            6 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Started by josh18955, 03-25-2023, 11:16 AM
            6 responses
            436 views
            0 likes
            Last Post Delerium  
            Started by FAQtrader, Today, 03:35 PM
            0 responses
            8 views
            0 likes
            Last Post FAQtrader  
            Started by rocketman7, Today, 09:41 AM
            5 responses
            19 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X