Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Double Variable or Data Series Perhaps?

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

    #16
    here is the verbatim of my output window:

    ty koganam for taking a look....



    ________________________
    **NT** Enabling NinjaScript strategy 'BasicPivot/34dceee39a114cdcac1add9fb6358a26' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True CalculateOnBarClose=True MaxRestarts=4 in 5 minutes
    0
    **NT** Error on calling 'OnBarUpdate' method for strategy 'BasicPivot/34dceee39a114cdcac1add9fb6358a26': You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

    _____________________________________


    I know its a basic message but why is calcing and printing a pivot borderline impossible for me right now on a system ive been using since early 2011. I mean today's pivot only requires a day of data, and then to compare it against each tick, no? i have set up the barsArray in this manner...

    Any advice appreciated.

    Regards,

    Andrew

    Comment


      #17
      Hello,

      Thanks for sending in the sample code.

      When using Daily bars, we need to ensure the Daily bar objects have been loaded. You can use ContainsValue(0) to do this:

      Code:
      			pivotPoint = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP[0];
      			
      			// Checks that this is a valid pivot point value
      			if (Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20).PP.ContainsValue(0))
      
      			{
      			
      					Print(pivotPoint);
      			}
      MatthewNinjaTrader Product Management

      Comment


        #18
        Originally posted by alabell View Post
        here is the verbatim of my output window:

        ty koganam for taking a look....



        ________________________
        **NT** Enabling NinjaScript strategy 'BasicPivot/34dceee39a114cdcac1add9fb6358a26' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True CalculateOnBarClose=True MaxRestarts=4 in 5 minutes
        0
        **NT** Error on calling 'OnBarUpdate' method for strategy 'BasicPivot/34dceee39a114cdcac1add9fb6358a26': You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

        _____________________________________


        I know its a basic message but why is calcing and printing a pivot borderline impossible for me right now on a system ive been using since early 2011. I mean today's pivot only requires a day of data, and then to compare it against each tick, no? i have set up the barsArray in this manner...

        Any advice appreciated.

        Regards,

        Andrew
        That message says that you have tried to access non-existent bars. You will need to escape the necessary number of bars. I do not think that the error is coming from your Pivots() statement, but rather from some other statement in your OnBarUpdate() section, most likely.

        Without seeing more of your code, I cannot point out where the error likely is. You can yourself just use judiciously placed Print() statements to determine which line is generating your error. You will not get valid Plot() values if your plot has an error.

        Comment


          #19
          Originally posted by koganam View Post
          That message says that you have tried to access non-existent bars. You will need to escape the necessary number of bars. I do not think that the error is coming from your Pivots() statement, but rather from some other statement in your OnBarUpdate() section, most likely.

          Without seeing more of your code, I cannot point out where the error likely is. You can yourself just use judiciously placed Print() statements to determine which line is generating your error. You will not get valid Plot() values if your plot has an error.
          I do not tend to use chart formations in this strategy, so i would ask:


          without using plot(), i see that the Print() returns that my day bars(these are indexed at "1") continuously return my error message "its our fault". It seems that there might be some issue with accessing yesterday's bar distinctly, especially if i boot up mid day, like i did today (PC replacement over the weekend). My question: I updated my historical data but is accesing yesterdays data inlive before today's close likely to be my issue?? or some derivation thereof?

          Thanks kindly,

          Andrew

          Comment


            #20
            Originally posted by alabell View Post
            ..., i see that the Print() returns that my day bars(these are indexed at "1") continuously return my error message "its our fault".
            Sorry, Andrew, I do not understand that statement. Is this a multi-timeframe strategy then?

            Comment


              #21
              yes indeed it is. i have 5 "Add" statements in inintialize.

              Tick Bars
              Volume Bars
              Minute Bars
              Day bars
              and for a completely superfluous reason, 3 minute bars.

              All of the above return

              "we're good"

              except for day bars.

              Comment


                #22
                Originally posted by alabell View Post
                yes indeed it is. i have 5 "Add" statements in inintialize.

                Tick Bars
                Volume Bars
                Minute Bars
                Day bars
                and for a completely superfluous reason, 3 minute bars.

                All of the above return

                "we're good"

                except for day bars.
                Code:
                private int _intEscapeBars = 3; //how many bars before we start processing, usually 1, made 3 here for illustration
                Code:
                        protected override void OnBarUpdate()
                        {
                            for (int index = 0; index < BarsArray.Length; index++) 
                            {
                                if (CurrentBars[index] < this._intEscapeBars) return;
                            }
                            // the rest goes here ... 
                        }
                When written this way, you do not have to even think about how many Bars objects you add to the indicator: the escapes will be automatically handled, dynamically, for the correct number of Bars objects.

                Comment


                  #23
                  wow...tremendous effort. thank you for your advice, i will get to implementation.

                  Regards,

                  Andrew

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by sjsj2732, Yesterday, 04:31 AM
                  0 responses
                  32 views
                  0 likes
                  Last Post sjsj2732  
                  Started by NullPointStrategies, 03-13-2026, 05:17 AM
                  0 responses
                  286 views
                  0 likes
                  Last Post NullPointStrategies  
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  283 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  133 views
                  1 like
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  91 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Working...
                  X