Page 1 of 1

Parabolic SAR

Posted: 04 Sep 2015 21:58
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

Re: Parabolic SAR

Posted: 07 Sep 2015 17:47
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

Re: Parabolic SAR

Posted: 07 Sep 2015 18:34
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

Re: Parabolic SAR

Posted: 09 Sep 2015 16:04
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

Re: Parabolic SAR

Posted: 23 Sep 2015 19:27
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

Re: Parabolic SAR

Posted: 24 Sep 2015 00:39
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);

Re: Parabolic SAR

Posted: 25 Sep 2015 10:29
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