Parabolic SAR

Post Reply
User avatar
GordonGekko
Posts: 33
Joined: 20 Jun 2014 09:57

Parabolic SAR

Post by GordonGekko »

Hallo liebe Trader-Gemeinde,

mir ist vor kurzem aufgefallen, dass der Parabolic SAR sich teilweise anders verhält, als beispielsweie in anderen Programmen, obwohl die Einstellungen identisch sind.
Habe daraufhin mal die Werte kontrolliert, indem ich die Werte nachgerechnet habe. Dabei fiel mir auf, dass der Parabolic SAR, der standardmäßig integriert ist,
nicht dem entspricht, wie die Formel definiert ist. Habe dann mal hier im Forum nach einem anderen gesucht und folgenden Code gefunden:

Code: Select all

Express ParabolicSAR

vars
input
$AccIncrement(0.00,1.00,0.02,0.01,2),
$AccMax(0.0,1.0,0.2,0.1,1);

series 
tendance,extreme,tmpSAR,SARlong,SARshort,x,y;

numeric facteur,tmp;

calculation
if IsFirstBar() then 
begin
  facteur = $AccIncrement; 
  tmpSAR = low; 
  extreme = low; 
  tendance = 1;
  SARlong = void;
  SARshort = void;   
end
else
begin
  if (tendance[1] = 1) then
  begin 
    extreme = max(extreme[1],high); 
    if (tmpSAR[1] > low) then
    begin 
      tendance = -1; 
      facteur = $AccIncrement; 
      tmp = max(high,high[1]); 
      tmpSAR = max(extreme,tmp); 
      extreme = low; 
      SARshort = void;
      SARlong = tmpSAR;
    end
    else
    begin 
      tendance = 1;
      if (extreme > extreme[1]) and (facteur < $AccMax) then
      begin 
        facteur = facteur + $AccIncrement; 
      end 
      tmpSAR = tmpSAR[1] + facteur*(extreme - tmpSAR[1]); 
      tmp = min(low,low[1]); 
      tmpSAR = min(tmpSAR,tmp);
      SARshort = tmpSAR;
      SARlong = void;
    end 
  end 
  else
  begin
    if (tendance[1] = -1) then
    begin
      extreme = min(extreme[1],low); 
      if (tmpSAR[1] < high) then
      begin 
        tendance = 1; 
        facteur = $AccIncrement; 
        tmp = min(low,low[1]); 
        tmpSAR = min(extreme,tmp); 
        extreme = high;
        SARshort = tmpSAR;
        SARlong = void;
      end 
      else
      begin 
        tendance = -1;
        if (extreme < extreme[1]) and (facteur < $AccMax) then 
        begin
          facteur = facteur + $AccIncrement; 
        end
        tmpSAR = tmpSAR[1] + facteur*(extreme - tmpSAR[1]); 
        tmp = max(high,high[1]); 
        tmpSAR = max(tmpSAR,tmp); 
        SARshort = void;
        SARlong = tmpSAR;
      end
    end
  end 
end

x = extreme;

interpretation 
begin
end

plot(tmpSAR,black,0);
plot(SARshort,green,2);
plot(SARlong,red,2);//@@@cs:778175-3661043-610814_cs@@@

Laut meinen Berechnungen entspricht diese Formel bzw. Code dem echten Parabolic SAR. Jedoch ist hier das Problem, dass dieser nicht zum backtesten verwendet werden kann. Weiterhin flippt der hier, wenn Hi/Lo über- oder unterschritten wird, besser wäre ein Close, wie beim standard-Parabolic-SAR. Ist es möglich den Fehler in dem Standard-Parabolic SAR zu beheben oder eben diesen hier eingefügten Code so anzupassen? Danke für Eure Zeit.

LG und ein schönes Wochenende
GG
User avatar
WHS Support
Posts: 2443
Joined: 14 Feb 2013 10:27

Re: Parabolic SAR

Post by WHS Support »

Hallo Gordon,

bei dem Express Code fehlt der Interpretation Teil - daher funktioniert dort der Backtest nicht. Wir haben diesen auf Basis Ihres Codes nun eingefügt:

Code: Select all

Express ParabolicSAR

vars
input
$AccIncrement(0.00,1.00,0.02,0.01,2),
$AccMax(0.0,1.0,0.2,0.1,1);

series 
tendance,extreme,tmpSAR,SARlong,SARshort,x,y;

numeric facteur,tmp;

calculation
if IsFirstBar() then 
begin
  facteur = $AccIncrement; 
  tmpSAR = low; 
  extreme = low; 
  tendance = 1;
  SARlong = void;
  SARshort = void;   
end
else
begin
  if (tendance[1] = 1) then
  begin 
    extreme = max(extreme[1],high); 
    if (tmpSAR[1] > low) then
    begin 
      tendance = -1; 
      facteur = $AccIncrement; 
      tmp = max(high,high[1]); 
      tmpSAR = max(extreme,tmp); 
      extreme = low; 
      SARshort = void;
      SARlong = tmpSAR;
    end
    else
    begin 
      tendance = 1;
      if (extreme > extreme[1]) and (facteur < $AccMax) then
      begin 
        facteur = facteur + $AccIncrement; 
      end 
      tmpSAR = tmpSAR[1] + facteur*(extreme - tmpSAR[1]); 
      tmp = min(low,low[1]); 
      tmpSAR = min(tmpSAR,tmp);
      SARshort = tmpSAR;
      SARlong = void;
    end 
  end 
  else
  begin
    if (tendance[1] = -1) then
    begin
      extreme = min(extreme[1],low); 
      if (tmpSAR[1] < high) then
      begin 
        tendance = 1; 
        facteur = $AccIncrement; 
        tmp = min(low,low[1]); 
        tmpSAR = min(extreme,tmp); 
        extreme = high;
        SARshort = tmpSAR;
        SARlong = void;
      end 
      else
      begin 
        tendance = -1;
        if (extreme < extreme[1]) and (facteur < $AccMax) then 
        begin
          facteur = facteur + $AccIncrement; 
        end
        tmpSAR = tmpSAR[1] + facteur*(extreme - tmpSAR[1]); 
        tmp = max(high,high[1]); 
        tmpSAR = max(tmpSAR,tmp); 
        SARshort = void;
        SARlong = tmpSAR;
      end
    end
  end 
end

x = extreme;

interpretation 
begin
  sentiment = 50;
  if ((SARlong[1] = void) AND (SARlong <> void)) then Sentiment = 0;
  if ((SARshort[1]= void) AND (SARshort <> void)) then Sentiment = 100;
end

plot(tmpSAR,black,0);
plot(SARshort,green,2);
plot(SARlong,red,2);//@@@cs:840968-3696051-671798_cs@@@
Bitte beachten Sie das wir keine Gewähr auf Richtigkeit des Codes oder der Interpreation übernehmen können. Bitte testen Sie daher den Indikator zunächst im Paperkonto. Vielen Dank für Ihr Verständnis.

Mit freundlichen Grüßen,
Timo
WH SELFINVEST
User avatar
GordonGekko
Posts: 33
Joined: 20 Jun 2014 09:57

Re: Parabolic SAR

Post by GordonGekko »

Hallo,

danke für die schnelle Hilfe.

Leider flippt der Parabolic SAR weiterhin nach dem schneiden vom High/Low und richtet sich nicht nach dem Close, wie der Standard-Indikator
in der FutureStation. Wäre Ihnen dankbar, wenn Sie das noch korrigieren könnten. Danke.

LG
GG
User avatar
GordonGekko
Posts: 33
Joined: 20 Jun 2014 09:57

Re: Parabolic SAR

Post by GordonGekko »

Hallo nochmal,

vielleicht ist es einfacher, wenn man den Code vom Standard-Indikator mit der Formel aus dem beigefügten Code abändert?
Kenne mich da nicht aus, nur ne Idee :)

LG
GG
User avatar
GordonGekko
Posts: 33
Joined: 20 Jun 2014 09:57

Re: Parabolic SAR

Post by GordonGekko »

Problem habe ich selbst gelöst.
Jedoch will ich nun den Indikator als Filter mit anderen Indikatoren nutzen, damit ich die Signale farblich angezeigt bekomme.
Leider komme ich nicht damit klar, da ich nicht weiß, wie ich Highlight slot integrieren kann.
Kann mir da jmd weiterhelfen?


LG

GordonGekko
mpcdmu
Posts: 19
Joined: 29 Jun 2013 00:11

Re: Parabolic SAR

Post by mpcdmu »

Bonjour GordonGekko, ( or Michael Douglas :D )

Voici un code qui pourra peut-être vous aider.

Cordialement.

Code: Select all

Express ImportParabolicSAR_Fitre

vars

series LongStops(ParabolicSAR.LongStops), ShortStops(ParabolicSAR.ShortStops);
numeric ;
input ;

calculation

//Option N° 1

//if (ShortStops[1] > Close[1])and (LongStops < Close)and IsBarCompleted() then HighlightRGB("slot", 120, 255, 120); 
//if (LongStops[1] < Close[1])and (ShortStops > Close)and IsBarCompleted() then HighlightRGB("slot", 255, 160, 192);

//Option N°2

if (ShortStops > Close)and IsBarCompleted() then HighlightRGB("slot", 255, 160, 192); 
if (LongStops < Close)and IsBarCompleted() then HighlightRGB("slot", 120, 255, 120);

interpretation
begin
end


plot(LongStops, lightblue, 3);
plot(ShortStops, magenta, 3);
You do not have the required permissions to view the files attached to this post.
User avatar
GordonGekko
Posts: 33
Joined: 20 Jun 2014 09:57

Re: Parabolic SAR

Post by GordonGekko »

Hi mpcdmu,

thanks a lot :D
Looks better now in my chart.

Just GordonGekko, not Michael Douglas ;)

Too many ideas, too big the lack of programming.


best regards
Post Reply

Return to “WHS NANOTRADER - EXPRESS PROGRAMMING”