[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Metastockusers] triple boxed ellipse indicator



PureBytes Links

Trading Reference Links

Wow ... be prepared for a deluge of responses for this ... :D
 
----- Original Message -----
From: Jose Silva
Sent: Friday, May 13, 2005 12:17 AM
Subject: [Metastockusers] triple boxed ellipse indicator

Due to the incredible response to the Ellipse indicator series (at
least two replies), below is the final indicator in the Ellipse
trilogy: triple Boxed Ellipse.

Note the re-use of variables to allow MetaStock to use 60 variables
(x3 maximum).


MetaStock -> Tools -> Indicator Builder -> New ->
Copy and paste complete formula between "---8<---" lines.

==============
Boxed Ellipses
==============
---8<--------------------------

{ Boxed Ellipses v2.0
  Box: High & Low of selected period.
  Ellipse: plots within Box boundaries.}
{ ©Copyright 2005 Jose Silva
  For personal use only.
  http://www.metastocktools.com }

pds1:=Input("Ellipse/Box width periods",
2,2600,40);
pds2:=Input("Ellipse/Box separation periods",
-26000,2600,5);
plot:=Input("plot:  [1]Box,  [2]Ellipse,  [3]Both",1,3,3);
pds2:=LastValue(If(pds2<=-pds1,-pds1+1,pds2));

{ Box & Ellipse 1 }
p2:=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;

If(plot=2,upperE,Hi);
If(plot=2,lowerE,Lo);
If(plot=2,upperE,top);
If(plot=2,lowerE,bot);
If(plot=1,top,upperE);
If(plot=1,bot,lowerE);

{ Box & Ellipse 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;
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;

If(plot=2,upperE,Hi);
If(plot=2,lowerE,Lo);
If(plot=2,upperE,top);
If(plot=2,lowerE,bot);
If(plot=1,top,upperE);
If(plot=1,bot,lowerE);

{ Box & Ellipse 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;

If(plot=2,upperE,Hi);
If(plot=2,lowerE,Lo);
If(plot=2,upperE,top);
If(plot=2,lowerE,bot);
If(plot=1,top,upperE);
If(plot=1,bot,lowerE)

---8<--------------------------


Yahoo! Groups Links

Yahoo! India Matrimony: Find your life partner online.