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