Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 12/14/2009(UTC) Posts: 140 Location: Austria
|
Here is a rash try by me - for getting the 4th highest value of the close for the last 5(6) day's ... but I'm not really sure if metastock can correctly work with such algorithm. Visualy it looks like it works. The next problem is the limitation of code in a metastock functions... ---- {nth's highest close value by ts-vienna} x1:=C; x2:=Ref(C,-1); x3:=Ref(C,-2); x4:=Ref(C,-3); x5:=Ref(C,-4); x6:=Ref(C,-5);
y1:=If(x1=Max(x1,x2),x1,x2); y2:=If(x1=Max(x1,x2),x2,x1); x1:=y1;x2:=y2; y2:=If(x2=Max(x2,x3),x2,x3); y3:=If(x2=Max(x2,x3),x3,x2); x2:=y2;x3:=y3; y3:=If(x3=Max(x3,x4),x3,x4); y4:=If(x3=Max(x3,x4),x4,x3); x3:=y3;x4:=y4; y4:=If(x4=Max(x4,x5),x4,x5); y5:=If(x4=Max(x4,x5),x5,x4); x4:=y4;x5:=y5; y5:=If(x5=Max(x5,x6),x5,x6); y6:=If(x5=Max(x5,x6),x6,x5); x5:=y5;x6:=y6;
y1:=If(x1=Max(x1,x2),x1,x2); y2:=If(x1=Max(x1,x2),x2,x1); x1:=y1;x2:=y2; y2:=If(x2=Max(x2,x3),x2,x3); y3:=If(x2=Max(x2,x3),x3,x2); x2:=y2;x3:=y3; y3:=If(x3=Max(x3,x4),x3,x4); y4:=If(x3=Max(x3,x4),x4,x3); x3:=y3;x4:=y4; y4:=If(x4=Max(x4,x5),x4,x5); y5:=If(x4=Max(x4,x5),x5,x4); x4:=y4;x5:=y5; y5:=If(x5=Max(x5,x6),x5,x6); y6:=If(x5=Max(x5,x6),x6,x5); x5:=y5;x6:=y6;
y1:=If(x1=Max(x1,x2),x1,x2); y2:=If(x1=Max(x1,x2),x2,x1); x1:=y1;x2:=y2; y2:=If(x2=Max(x2,x3),x2,x3); y3:=If(x2=Max(x2,x3),x3,x2); x2:=y2;x3:=y3; y3:=If(x3=Max(x3,x4),x3,x4); y4:=If(x3=Max(x3,x4),x4,x3); x3:=y3;x4:=y4; y4:=If(x4=Max(x4,x5),x4,x5); y5:=If(x4=Max(x4,x5),x5,x4); x4:=y4;x5:=y5; y5:=If(x5=Max(x5,x6),x5,x6); y6:=If(x5=Max(x5,x6),x6,x5); x5:=y5;x6:=y6;
y1:=If(x1=Max(x1,x2),x1,x2); y2:=If(x1=Max(x1,x2),x2,x1); x1:=y1;x2:=y2; y2:=If(x2=Max(x2,x3),x2,x3); y3:=If(x2=Max(x2,x3),x3,x2); x2:=y2;x3:=y3; y3:=If(x3=Max(x3,x4),x3,x4); y4:=If(x3=Max(x3,x4),x4,x3); x3:=y3;x4:=y4; y4:=If(x4=Max(x4,x5),x4,x5); y5:=If(x4=Max(x4,x5),x5,x4); x4:=y4;x5:=y5; y5:=If(x5=Max(x5,x6),x5,x6); y6:=If(x5=Max(x5,x6),x6,x5); x5:=y5;x6:=y6;
y1:=If(x1=Max(x1,x2),x1,x2); y2:=If(x1=Max(x1,x2),x2,x1); x1:=y1;x2:=y2; y2:=If(x2=Max(x2,x3),x2,x3); y3:=If(x2=Max(x2,x3),x3,x2); x2:=y2;x3:=y3; y3:=If(x3=Max(x3,x4),x3,x4); y4:=If(x3=Max(x3,x4),x4,x3); x3:=y3;x4:=y4; y4:=If(x4=Max(x4,x5),x4,x5); y5:=If(x4=Max(x4,x5),x5,x4); x4:=y4;x5:=y5; y5:=If(x5=Max(x5,x6),x5,x6); y6:=If(x5=Max(x5,x6),x6,x5); x5:=y5;x6:=y6;
y1:=If(x1=Max(x1,x2),x1,x2); y2:=If(x1=Max(x1,x2),x2,x1); x1:=y1;x2:=y2; y2:=If(x2=Max(x2,x3),x2,x3); y3:=If(x2=Max(x2,x3),x3,x2); x2:=y2;x3:=y3; y3:=If(x3=Max(x3,x4),x3,x4); y4:=If(x3=Max(x3,x4),x4,x3); x3:=y3;x4:=y4; y4:=If(x4=Max(x4,x5),x4,x5); y5:=If(x4=Max(x4,x5),x5,x4); x4:=y4;x5:=y5; y5:=If(x5=Max(x5,x6),x5,x6); y6:=If(x5=Max(x5,x6),x6,x5); x5:=y5;x6:=y6;
x1;x2;x3;x4;C;
{x4 should be the 4th highest value) ----
maybe you can simplify it a little bit.. (I have only copy-pasted the "middle"-block- part.. because of the lack of a loop in ms)
|