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

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:
    Dive into manipulating C# code from within an unlocked NinjaScript strategy using the NinjaScript Editor.NinjaTrader 7 is an award winning end to end online ...


    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 Radano, 06-10-2021, 01:40 AM
        19 responses
        604 views
        0 likes
        Last Post Radano
        by Radano
         
        Started by KenneGaray, Today, 03:48 AM
        0 responses
        3 views
        0 likes
        Last Post KenneGaray  
        Started by thanajo, 05-04-2021, 02:11 AM
        4 responses
        470 views
        0 likes
        Last Post tradingnasdaqprueba  
        Started by aa731, Today, 02:54 AM
        0 responses
        5 views
        0 likes
        Last Post aa731
        by aa731
         
        Started by Christopher_R, Today, 12:29 AM
        0 responses
        10 views
        0 likes
        Last Post Christopher_R  
        Working...
        X