logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
ALGORITHM  
#1 Posted : Wednesday, February 25, 2009 5:18:51 PM(UTC)
ALGORITHM

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 2/26/2009(UTC)
Posts: 2

hi all, ive managed to write myself some formulas but now want to find the daily minimum value of a moving average ribbon formula. i would expect to write this by including the moving average formula within min(). but metastock seems to want a ',' somewhere within the syntax. i cannot work out where the comma should go since there are semi-colons within the moving average formula. can someone help me find the minimum value of the moving average formula below (ie the lowest value of any of the moving average lines on any day). thanks. Periods := Input("Time Periods", 1, 1000, 20); Spacing := Input("Spacing", 1, 100, 5); Ribbons := Input("Ribbons", 1, 12, 12); BaseMA := Mov(C,Periods+(Spacing*0),S); If(Ribbons>=2,Mov(C,Periods+(Spacing*1),S),BaseMA); If(Ribbons>=3,Mov(C,Periods+(Spacing*2),S),BaseMA); If(Ribbons>=4,Mov(C,Periods+(Spacing*3),S),BaseMA); If(Ribbons>=5,Mov(C,Periods+(Spacing*4),S),BaseMA); If(Ribbons>=6,Mov(C,Periods+(Spacing*5),S),BaseMA); If(Ribbons>=7,Mov(C,Periods+(Spacing*6),S),BaseMA); If(Ribbons>=8,Mov(C,Periods+(Spacing*7),S),BaseMA); If(Ribbons>=9,Mov(C,Periods+(Spacing*8),S),BaseMA); If(Ribbons>=10,Mov(C,Periods+(Spacing*9),S),BaseMA); If(Ribbons>=11,Mov(C,Periods+(Spacing*10),S),BaseMA); If(Ribbons>=12,Mov(C,Periods+(Spacing*11),S),BaseMA);
wabbit  
#2 Posted : Wednesday, February 25, 2009 5:35:08 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Hi Algorithm,

Welcome to the forum.

In order to use the Min() (and later the Max() ) functions, you should assign each moving average line to a variable then test each variable against each other variable. Something like:


------

Periods := Input("Time Periods", 1, 1000, 20);
Spacing := Input("Spacing", 1, 100, 5);
Ribbons := Input("Ribbons", 1, 12, 12);

ma0 := Mov(C,Periods+(Spacing*0),S);

ma1:=If(Ribbons>=2,Mov(C,Periods+(Spacing*1),S),ma0);
ma2:=If(Ribbons>=3,Mov(C,Periods+(Spacing*2),S),ma0);
ma3:=If(Ribbons>=4,Mov(C,Periods+(Spacing*3),S),ma0);
ma4:=If(Ribbons>=5,Mov(C,Periods+(Spacing*4),S),ma0);
ma5:=If(Ribbons>=6,Mov(C,Periods+(Spacing*5),S),ma0);
ma6:=If(Ribbons>=7,Mov(C,Periods+(Spacing*6),S),ma0);
ma7:=If(Ribbons>=8,Mov(C,Periods+(Spacing*7),S),ma0);
ma8:=If(Ribbons>=9,Mov(C,Periods+(Spacing*8),S),ma0);
ma9:=If(Ribbons>=10,Mov(C,Periods+(Spacing*9),S),ma0);
ma10:=If(Ribbons>=11,Mov(C,Periods+(Spacing*10),S),ma0);
ma11:=If(Ribbons>=12,Mov(C,Periods+(Spacing*11),S),ma0);

mn:=Min(Min(Min(Min(Min(Min(Min(Min(Min(Min(Min(ma0,ma1),ma2),ma3),ma4),ma5),ma6),ma7),ma8),ma9),ma10),ma11);
mx:=Max(Max(Max(Max(Max(Max(Max(Max(Max(Max(Max(ma0,ma1),ma2),ma3),ma4),ma5),ma6),ma7),ma8),ma9),ma10),ma11);

{plot}
ma0;ma1;ma2;ma3;ma4;ma5;ma6;ma7;ma8;ma9;ma10;ma11;
mn;
mx;

----------------------


Hope this helps.

wabbit [:D]

ALGORITHM  
#3 Posted : Thursday, February 26, 2009 12:41:36 AM(UTC)
ALGORITHM

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 2/26/2009(UTC)
Posts: 2

thats great thanks wabbit.
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.