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 CarlTrading, Yesterday, 09:41 PM
          1 response
          20 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, Today, 02:41 AM
          0 responses
          7 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, Yesterday, 11:44 PM
          0 responses
          18 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          35 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          33 views
          0 likes
          Last Post CarlTrading  
          Working...
          X