• 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

Built-In Parabolic SAR

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

    Built-In Parabolic SAR

    Good Morning,
    I'm calling the built-in indicator into my strategy. Sometimes, (not every time) I'm getting the following error message:
    Indicator 'Parabolic SAR': Error on calling 'OnBarUpdate' method on bar 1254: 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.
    Not sure what to fix since I normally change this piece of code when I see this error:


    Code:
    if (CurrentBar < 3)
    				return;
    But since it also has this, I'm not sure what to do...
    Code:
    			if (CurrentBar == 3)
    			{
    				// Determine initial position
    				longPosition = High[0] > High[1];
    				xp = longPosition ? MAX(High, CurrentBar)[0] : MIN(Low, CurrentBar)[0];
    				af = Acceleration;
    				Value[0] = xp + (longPosition ? -1 : 1) * ((MAX(High, CurrentBar)[0] - MIN(Low, CurrentBar)[0]) * af);
    				return;
    			}
    			else if (BarsArray[0].BarsType.IsRemoveLastBarSupported && CurrentBar < prevBar)
    			{....
    Please provide direction to make sufficient modifications so this will not cause error messages. Thanks.

    #2
    Hello zeller4,

    Thank you for writing in.

    I would suggest adding prints to the script to isolate where the error is coming as we don't have enough information to debug the issue.

    For example you could add on different lines of the script,

    Code:
    Print("Making it to line line 89");
    Print("Making it to line line 100");
    Print("Making it to line line 110");
    This way when the output window is open, you can isolate what line is throwing the error. If you take this approach, can you provide the line which causes the error?

    I’ve provided a link to a youtube video which covers an example of using prints to understand behavior:
    https://www.youtube.com/watch?v=K8v_...tu.be&t=48m45s
    I’ve provided a link covering debugging which you may find helpful.

    Debugging: http://ninjatrader.com/support/forum...ead.php?t=3418

    If you try the above and still unable to figure out the issue, please leave the print statements in the script and you can upload a copy and I'll take a look and see if anything jumps out.

    To export a NinjaScript from NinjaTrader 8 do the following:
    From the Control Center window select Tools -> Export -> NinjaScript...
    Click Add>Select the indicator>OK>Export.
    Then attach that file you saved; under My Docs>NT8>Bin>Custom>Select the downloaded .zip file.

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

    Comment


      #3
      Since this is happening to the built-in NT indicator within my strategy, are you saying that adding print statements in my strategy will allow me to see how far the code made it through the Parabolic SAR code before it prints? Why would it create an error only sometime and not every time? It appears to me a try/catch block should be added to the NT built-in indicator to find out why it kicks out...
      Last edited by zeller4; 09-25-2018, 08:33 AM.

      Comment


        #4
        Hello zeller4,

        I overlooked that the code you posted was from the ParabolicSar and not your strategy, so no the prints wouldn't work in the strategy, however you could save a copy of the Parabolic Sar and add those prints in the copy to determine where the issue gets triggered. Try Catches would also be a good approach.

        Is there a specific instrument, time frame, bar type, day of the week, which triggers this error?

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

        Comment


          #5
          Using it on CL 11-18 on a UniRenko 242, today it kicked out 3 times but then allowed me to use it again... so it's running now. Not sure what is the bug?

          Comment


            #6
            Hello zeller4,

            Could you provide the strategy which gets this error?

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

            Comment


              #7
              AlanP,
              It's a highly customized set of indicators inside a customized strategy. Got any other suggestions?

              Comment


                #8
                Hello zeller4,

                I think the prints on different lines of a replicated Parabolic indicator would be the quickest way of finding the issue. Next time it happens, check the log, see the line.

                You could also debug with VS, however if it doesn't happen every time this approach may not be best. See,
                https://ninjatrader.com/support/help..._debugging.htm

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

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by stevenev1, Today, 01:43 PM
                0 responses
                3 views
                0 likes
                Last Post stevenev1  
                Started by shinuvu, Today, 11:05 AM
                2 responses
                11 views
                0 likes
                Last Post shinuvu
                by shinuvu
                 
                Started by Hagar, Yesterday, 07:12 PM
                1 response
                14 views
                0 likes
                Last Post NinjaTrader_ChrisL  
                Started by PBreen, Today, 11:59 AM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_ShawnB  
                Started by johnnybegoode, 01-14-2019, 07:24 PM
                13 responses
                544 views
                0 likes
                Last Post seeseea
                by seeseea
                 
                Working...
                X