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

Notification

Icon
Error

Options
Go to last post Go to first unread
RUTrading  
#1 Posted : Monday, February 25, 2013 10:03:30 AM(UTC)
RUTrading

Rank: Member

Groups: Registered, Registered Users, Unverified Users
Joined: 6/12/2012(UTC)
Posts: 19
Location: South Africa - JHB

Hi,

I am trying to work out how to see if a moving average is rising or falling. I have read the Formula Primer, but still battle to understand everything, its one thing to read it, its another thing to apply it. This is what I have found from the forms for a rising trend or falling trend so far and I am now trying to interrupt what it means.

{ A:=Mov(C,30,S);
B:=If(Sum(A>Ref(A,-1),11)>5,1,If(Sum(A<Ref(A,-1),11)>5,-1,0));
B; }

I am not understanding the 5 in this above formula stands for? and 1, -1 or 0 ????

Could someone tell me also if the below formula would work better than the above one to find a rising moving average ???????

{Pd:=30;
Mov(C,pd,S)>Ref(Mov(C,pd,S),-1) }

Lastly, I have also seen somewhere on this forum someone talking of using ROC() to find a raising trend, how would I do that???

Appreciate the help in advance.

Rutrading





John S  
#2 Posted : Tuesday, February 26, 2013 10:02:47 AM(UTC)
John S

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/9/2012(UTC)
Posts: 169

I let Wabbit and MSTT do the heavy lifting on the formula stuff, but I think I might can handle this one.

First, you'll need to remove the brackets { and } from your formula otherwise nothing will plot.

The first formula reads like this:

A:=Mov(C,30,S);
B:=If(Sum(A>Ref(A,-1),11)>5,1,If(Sum(A<Ref(A,-1),11)>5,-1,0));
B;

If a 30-period simple moving average has gone up more than 5 times over the last 11 periods, then plot a "1". If its gone down more than 5 of the last 11 then plot a "-1". If neither is true, then plot a "0".

The second formula reads like this:

Pd:=30;
Mov(C,pd,S)>Ref(Mov(C,pd,S),-1)

The 30-period simple moving average is greater than the previous period's. If this is TRUE then a "1" will plot; otherwise it plots "0".

Neither of these may produce what you are looking for. The MA could still be trending down, yet still have 6 (or more) rising values.

You could add one more variable that gets you closer to this.

A:=Mov(C,30,S);
B:=If(Sum(A>Ref(A,-1),11)>5,1,If(Sum(A<Ref(A,-1),11)>5,-1,0));
C: A>ref(A,-11);
B AND C;

I haven't actually done any of the above in MetaStock, so there could indeed be some syntax errors.

--john




RUTrading  
#3 Posted : Wednesday, February 27, 2013 5:13:52 AM(UTC)
RUTrading

Rank: Member

Groups: Registered, Registered Users, Unverified Users
Joined: 6/12/2012(UTC)
Posts: 19
Location: South Africa - JHB

Hi John

Great help, Could you just explain this part:

C: A>ref(A,-11);

Does this mean that the 30 simple moving average today is greater than it has been in the last 11 periods. If so does that not eliminate the part of the forumla saying it must have gone up 5 times over the last 11 periods.

Do you know how you would use ROC() to find the MA rising?

Here is my attempt without testing it, but I have no clue what I am doing:

ROC(Mov(C,30,S)>Ref(Mov(C,30), -1),1,%)

Thanks again for your help.
John S  
#4 Posted : Wednesday, February 27, 2013 10:46:58 AM(UTC)
John S

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/9/2012(UTC)
Posts: 169

"Does this mean that the 30 simple moving average today is greater than it has been in the last 11 periods." No. It means that today's is greater than the value exactly 11 periods ago. You'd need to use the HHV() function to check if its greater than all values. (I actually plotted this and saw that I had some syntax errors...so I cleaned up below) Use the HHV() like this:

X:=Mov(C,30,S);
Y:=If(Sum(X>Ref(X,-1),11)>5,1,If(Sum(X<Ref(X,-1),11)>5,-1,0));
Z:=X>=HHV(X,11);
Y AND Z;


I'd forget about the ROC() function. But yeah you could use it.
RUTrading  
#5 Posted : Thursday, February 28, 2013 9:49:01 PM(UTC)
RUTrading

Rank: Member

Groups: Registered, Registered Users, Unverified Users
Joined: 6/12/2012(UTC)
Posts: 19
Location: South Africa - JHB

Thanks John for the help, I have tested it and very happy.
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.