Parabolic SAR

Post Reply
Jonas
Posts: 11
Joined: 02 Feb 2014 09:43

Parabolic SAR

Post by Jonas »

At the moment i`am trying to reimplement the Parabolic SAR.

I can not find my mistake by now. I hope that i have understand the algorithm correct.

This is my code:

Code: Select all

Express ParabolicTest


//  -----------------------------------------------------
Vars
//  -----------------------------------------------------

  
series up, down;
bool long, short;
numeric SIP,af, hoch, tief;

//  -----------------------------------------------------
Calculation
//  -----------------------------------------------------

if(IsFirstBar()) then
begin
  af=0.02;
  long=true;
  short=false;
  up=low;
  down=void;
  SIP=high;
end
else begin
  if(long) then
  begin
    up[0]=up[1]+af*(SIP-up[1]);
    down[0]=void;
    if(SIP<high) then 
    begin
      SIP=high;
      af=af+0.02;
      if(af>0.2) then af=0.2;
    end
    if(high>up[0]) then
    begin
      short=true;
      long=false;
      down[0]=SIP;
      SIP=low;
      af=0.02;
    end
  end
  else
  begin
    down[0]=down[1]+af*(SIP-up[1]);
    up[0]=void;
    if(SIP>low) then 
    begin
      SIP=low;
      af=af+0.02;
      if(af>0.2) then af=0.2;
    end
    if(low<down[0]) then
    begin
      short=false;
      long=true;
      up[0]=SIP;
      SIP=high;
      af=0.02;
    end
  end
end


//  -----------------------------------------------------
interpretation
//  -----------------------------------------------------
begin
end


plot (down,  255,  0,   0, 2) ;  // red
plot (up,   0, 255,   0, 2) ;  // green
User avatar
WHS Support
Posts: 2430
Joined: 14 Feb 2013 10:27

Re: Parabolic SAR

Post by WHS Support »

Hello Jonas,

unfortunately I can not help you evaluate your code but please find another version of the PSAR attached in Express format. You can use and modify it as you like. Maybe it also helps you with your code.

Kind regards,
Timo
WH SelfInvest
You do not have the required permissions to view the files attached to this post.
Post Reply

Return to “WHS NANOTRADER - EXPRESS PROGRAMMING”