• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error 'You are accessing an index with a value' for indicator requiring tick replay

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

    Error 'You are accessing an index with a value' for indicator requiring tick replay

    Hey guys,

    I'm likely doing something wrong for this simple request but I'm just trying to load this custom indicator that uses the OrderFlowCumulativeDelta indicator and print out the values. But, my output window is just saying:

    Error on calling 'OnBarUpdate' method on bar 20: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

    I've attached the custom indicator and my simple script. Can you offer a hand?

    Thank you.
    Attached Files

    #2
    Hello PN720,

    I see you have a CurrentBars check for the primary series, however you do not for the added series.

    Do you still see the error if you change:
    Code:
     
     if (CurrentBars[0] < 10 ) return;
    to
    Code:
    if (CurrentBars[0] < 10 || CurrentBars[1] < 10 ) return;
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Ah, of course! It had to be something simple like that. Corrected syntax now reads:

      Code:
      if (CurrentBars[0] < 10 || CurrentBars[1] < 10 ) return;
      
      if (BarsInProgress == 0)
      {
      Print (Time[0] + " - Delta Up: " + DeltaInd.UpMomo[0] + ". Delta Down: " + DeltaInd.DownMomo[0]);
      }
      I have another question, though. When I run this code against a 1 minute chart and have Tick Replay checked, I just get zeros for values. If I change to BarsInProgress == 1, I get values but it's echoing out for every 1 tick. Is it not possible for me to show it for every 1 minute?

      Comment


        #4
        Hello PN720,

        In the indicator it looks like you are only assigning a plot value in BarsInProgress = 1, do you see the same problem if you assign the values from BarsInProgress=0 instead?

        The sample requires using BIP1 for updating the indicator, however the rest of your logic can reside in BIP0:

        Code:
        if (BarsInProgress == 0)
                    {
        
                          //Print("Delta Close: " + cumulativeDelta.DeltaClose[0]);   //where you would otherwise normally use the delta value
                    }
        else if (BarsInProgress == 1)
                    {
                          // We have to update the secondary series of the hosted indicator to make sure the values we get in BarsInProgress == 0 are in sync
                          // mainly used for updating. 
                          cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
        Can you try moving the indicator logic into BIP 0 and then retest? I would likely need to dig into this further if that is not the case, this is the most obvious item I can see looking at the code.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse,
          I found a workaround to this so I'm good now, thanks for your help!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by rexmie888, Yesterday, 09:37 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_ChrisSch  
          Started by larkmail, Yesterday, 06:19 PM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Marco  
          Started by jvanelli, Yesterday, 09:23 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Marco  
          Started by lavalampmj, Yesterday, 06:07 PM
          1 response
          10 views
          0 likes
          Last Post bltdavid  
          Started by Sameer, Yesterday, 04:40 PM
          1 response
          35 views
          0 likes
          Last Post NinjaTrader_EricB  
          Working...
          X