Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

object error ????

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

    object error ????

    I am trying to get the range of the overnight session this is what I have and I still get an object error.

    If I turn on the for statement I get the error
    Error on calling 'OnBarUpdate' method on bar 0: 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.



    //GIVEN: nMar****pen, nMarketClose
    //TASK: gets the overnight range of the market
    //RETURN: high and low of the overnight range
    public void getFibanacciRangeTimes()
    {
    Print(Bars.Count);
    // if(Bars.Count > 100)
    // {
    int nDayStart = Bars.GetBar(dMar****pen.AddMinutes(-30));
    int nDayEndIndex1 = Bars.GetBar(dMarketClose.AddDays(-1));
    Print("Day start index " + nDayStart);
    Print("Day end index " + nDayEndIndex1);
    Print(Bars.Count + "Bars coutn");
    if(Bars.Count > nDayStart)
    {
    for(int nTempCount = nDayEndIndex1; nTempCount < nDayStart; nTempCount = nTempCount + 1)
    {
    if (dFibHigh < High[nTempCount])
    dFibHigh = High[nTempCount];

    if (dFibLow > Low[nTempCount])
    dFibLow = Low[nTempCount];

    }
    }

    Print("Fib High is " + dFibHigh);
    Print("Fib Low is " + dFibLow);

    }

    #2
    Hello ballboy11,

    I would suggest adding print statements to check whether your conditions are becoming true, the value of your variables, for example Bars.Count. I’ve provided a link to a youtube video which covers an example of using prints to understand behavior:


    I’ve provided a link covering debugging which you may find helpful.
    Debugging: http://ninjatrader.com/support/forum...ead.php?t=3418

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      I did use print statements but this is where I am at.

      Comment


        #4
        Hello ballboy11,

        Without the full code we're unable to test on our end.

        If you'd like to upload the full code I can take a look and see if anything jumps out. Or if you'd prefer to email a copy, send to platformsupport[at]ninjatrader[dot]com with Attn: Alan P in the Subject line. Also within the email please include a link to this thread, and the files.

        I look forward to your reply.
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        581 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        338 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 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
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X