Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Parabolic SAR inconsistency in Strategy

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

    Parabolic SAR inconsistency in Strategy

    I started seeing some inconsistent numbers while implementing a strategy using Parabolic SAR. I have reduced it to the following recreatable problem on my end:
    In OnBarUpdate() I have the following 2 statements:
    Print("1. PSar for last bar is : " + ParabolicSAR(psarAcc,psarMaxStep,psarStep)[1].ToString());
    Print("2. PSar for last bar is : " + ParabolicSAR(.02,.2,.02)[1].ToString());
    In the variables section:
    private double psarAcc = 0.02; // Default setting for PsarAcc
    private double psarMaxStep = 0.2; // Default setting for PsarMaxStep
    private double psarStep = 0.02; // Default setting for PsarStep

    So the same variables being passed. And yet, here is a sample output:
    1. PSar for last bar is : 396.7
    2. PSar for last bar is : 395.308
    1. PSar for last bar is : 396.9
    2. PSar for last bar is : 395.48152
    1. PSar for last bar is : 396.9
    2. PSar for last bar is : 395.7549984

    And by the way, the chart display with the Parabolic SAR indicator with same parameters has no correlation to any of the numbers above.

    Why 3 separate results for each instance ?

    #2
    Hi nybangali, please check if your called ParabolicSAR indicator uses a CalculateOnBarClose reference in the Initialize(). If yes delete it and check the results again. Thanks!

    Comment


      #3
      nybangali,

      Please see if this fix addresses your issues. Thank you.

      Edit: A more up-to-date version has been uploaded. Please redownload.
      Attached Files
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Hi,

        I also have an "inconsistency" problem with ParabolicSAR.

        I'm telling the strategy to exit any Long position if the ParabolicSAR jumps from below the bars to above the bars, and to exit any Short position vice versa. However, it won't do it (in backtesting).

        Here's the code:
        Code:
        if ((High[0] == maxHigh 
        				|| 
        				(
        				ParabolicSAR(para,paraMid,para)[1] < Close[1] 
        				&& ParabolicSAR(para,paraMid,para)[0] > Close[0]
        				)
        				)
        				&& Position.MarketPosition == MarketPosition.Long
        				)
        			{
        				ExitLong();				
        			}
        (maxHigh is the last 8 bars' high).

        Any ideas, anyone?

        Greetz
        noincomenojobnoassets

        Comment


          #5
          noincomenojobnoassets,

          You should not be working off of ParabolicSAR(). Please use the "fix" version.
          Josh P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          144 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          71 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          125 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          79 views
          0 likes
          Last Post PaulMohn  
          Working...
          X