Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
[code:1:0461483b5d]
{ Seismic indicator v1.0
Plot on price chart.
©Copyright 2005 Jose Silva.
http://www.metastocktools.com
W/thanks to MG Ferreira for ellipse equation.}
pds1:=Input("Seismic width periods",2,2600,30);
pds2:=Input("Seismic separation periods",
-26000,2600,-10);
pds2:=LastValue(If(pds2<=-pds1,-pds1+1,pds2));
{ Seismic 1 }
p2:=pds1;
p1:=pds1+p2;
start:=Cum(1)=LastValue(Cum(1))-p1;
end:=Cum(1)=LastValue(Cum(1))-p2;
restrict:=Ref(Ref(ValueWhen(1,start,1),-p2),p2);
Hi:=LastValue(Highest(ValueWhen(1,restrict,H)))
+restrict-1;
Lo:=LastValue(Lowest(ValueWhen(1,restrict,L)))
+restrict-1;
midX:=(p1-p2)/2;
midY:=(Hi-Lo)/2;
tX:=Cum(1)-midX-(LastValue(Cum(1))-p1);
ellipse:=
Sqrt(midY*midY*(1-Min(tX*tX/midX/midX,1)));
upperE:=Lo+midY+ellipse;
lowerE:=Hi-midY-ellipse;
upperE;lowerE;
{ Seismic 2 }
p2:=p1+pds2;
p1:=pds1+p2;
start:=Cum(1)=LastValue(Cum(1))-p1;
end:=Cum(1)=LastValue(Cum(1))-p2;
restrict:=Ref(Ref(ValueWhen(1,start,1),-p2),p2);
Hi:=LastValue(Highest(ValueWhen(1,restrict,H)))
+restrict-1;
Lo:=LastValue(Lowest(ValueWhen(1,restrict,L)))
+restrict-1;
midX:=(p1-p2)/2;
midY:=(Hi-Lo)/2;
tX:=Cum(1)-midX-(LastValue(Cum(1))-p1);
ellipse:=
Sqrt(midY*midY*(1-Min(tX*tX/midX/midX,1)));
upperE:=Lo+midY+ellipse;
lowerE:=Hi-midY-ellipse;
upperE;lowerE;
{ Seismic 3 }
p2:=p1+pds2;
p1:=pds1+p2;
start:=Cum(1)=LastValue(Cum(1))-p1;
end:=Cum(1)=LastValue(Cum(1))-p2;
restrict:=Ref(Ref(ValueWhen(1,start,1),-p2),p2);
Hi:=LastValue(Highest(ValueWhen(1,restrict,H)))
+restrict-1;
Lo:=LastValue(Lowest(ValueWhen(1,restrict,L)))
+restrict-1;
top:=If(start OR end,Lo,Hi);
bot:=If(start OR end,Hi,Lo);
midX:=(p1-p2)/2;
midY:=(Hi-Lo)/2;
tX:=Cum(1)-midX-(LastValue(Cum(1))-p1);
ellipse:=
Sqrt(midY*midY*(1-Min(tX*tX/midX/midX,1)));
upperE:=Lo+midY+ellipse;
lowerE:=Hi-midY-ellipse;
upperE;lowerE;
{ Seismic 4 }
p2:=p1+pds2;
p1:=pds1+p2;
start:=Cum(1)=LastValue(Cum(1))-p1;
end:=Cum(1)=LastValue(Cum(1))-p2;
restrict:=Ref(Ref(ValueWhen(1,start,1),-p2),p2);
Hi:=LastValue(Highest(ValueWhen(1,restrict,H)))
+restrict-1;
Lo:=LastValue(Lowest(ValueWhen(1,restrict,L)))
+restrict-1;
top:=If(start OR end,Lo,Hi);
bot:=If(start OR end,Hi,Lo);
midX:=(p1-p2)/2;
midY:=(Hi-Lo)/2;
tX:=Cum(1)-midX-(LastValue(Cum(1))-p1);
ellipse:=
Sqrt(midY*midY*(1-Min(tX*tX/midX/midX,1)));
upperE:=Lo+midY+ellipse;
lowerE:=Hi-midY-ellipse;
upperE;lowerE
[/code:1:0461483b5d]
jose '-)
|