logo
  • Home
  • Discussions
  • Files
  • Register
  • Login
Welcome Guest! To enable all features please Login or Register.
  • Forum
  • Active Topics
  • Search
  • Help
  • Login
  • Register
  Search Search

Notification

Icon
Error

OK


Discussions  »  Product and Service Development  »  Formula Assistance  »  How to write a formula to identify a moving average that is trending up in last month
How to write a formula to identify a moving average that is trending up in last month - i want to identify charts that have the 200 day moving average line trending up.
Options
  • Email this topic Email this topic
  • Watch this topic Watch this topic
  • Print this topic Print this topic
  • » Normal
  • Threaded
Go to last post Go to first unread
Previous Topic Next Topic
Anne Austin  
#1 Posted : Tuesday, October 25, 2022 7:17:16 AM(UTC)
Anne Austin

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 9/15/2022(UTC)
Posts: 6
Location: Perth

i am stuck!

I want to find stocks that are sitting above the 200 day moving average, but I also want the 200 day moving average line to be pointing up for at least the last month, not down or flat.

this is kind of what I want to write:

C > MOV (C,200,S) AND

Ref (MOV(C,200,S)) > Ref,-20 (MOV(C,200,S))

...

but that is not quite acceptible to metastock yet!

Can you please help me, wabbit!

Back to top
  • User Profile
  • View All Posts by User
  • View Thanks

Wanna join the discussion?! Login to your Discussions forum accountor Register a new forum account.

Back to top  
Anne Austin  
#2 Posted : Tuesday, October 25, 2022 7:46:45 AM(UTC)
Anne Austin

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 9/15/2022(UTC)
Posts: 6
Location: Perth

i have another problem, which I thought I had solved but it turns out I didn't!

I want to identify all stocks sitting above the 200 day, 150 day and 50 day moving averages.

I wrote that formula correctly.

C >Mov(C,200,S) AND C >Mov(C,150,S) C >Mov(C,50,S)

But I also wanted to identify only those stocks where the 50day moving average sat above the 150 d moving average and the 150 day moving average sat above the 200 day moving average.

This was the formula I added to the formula above, but it didn't seem to cull out the stocks whose moving averages were in the wrong position:

Mov(C,50,S) > Mov(C,150,S) >Mov(C,200,S)

...

basically, what I want is to be able to identify stocks sitting above the 200 d, 150 d and 50 d moving averages, and where the 50 dma sits above the 150dma and the 150dma sits above the 200 dma, and where the 200 dma line is sloping up for at least the last 20 trading days!
​​​​​​​

Can you please help me!

Back to top
  • User Profile
  • View All Posts by User
  • View Thanks
MS Support  
#3 Posted : Tuesday, October 25, 2022 2:32:19 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,847

Thanks: 79 times
Was thanked: 148 time(s) in 144 post(s)
Originally Posted by: Anne Austin Go to Quoted Post

i have another problem, which I thought I had solved but it turns out I didn't!

I want to identify all stocks sitting above the 200 day, 150 day and 50 day moving averages.

I wrote that formula correctly.

C >Mov(C,200,S) AND C >Mov(C,150,S) C >Mov(C,50,S)

But I also wanted to identify only those stocks where the 50day moving average sat above the 150 d moving average and the 150 day moving average sat above the 200 day moving average.

This was the formula I added to the formula above, but it didn't seem to cull out the stocks whose moving averages were in the wrong position:

Mov(C,50,S) > Mov(C,150,S) >Mov(C,200,S)

...

basically, what I want is to be able to identify stocks sitting above the 200 d, 150 d and 50 d moving averages, and where the 50 dma sits above the 150dma and the 150dma sits above the 200 dma, and where the 200 dma line is sloping up for at least the last 20 trading days!
​​​​​​​

Can you please help me!


Hello, I would make sure to use the Booleans (AND) carefully in this case. You could define the slope a few ways, but if you are simply looking for a positive rate of change every day for 20 days, you could write it as follows:

Code:
C > Mov(C,50,S) AND C > Mov(C,150,S) AND C > Mov(C,200,S) AND Mov(C,50,S) > Mov(C,150,S) AND Mov(C,150,S) >Mov(C,200,S) AND Sum(ROC(Mov(C,200,S),1,$) > 0,20) = 20

So the ROC (Rate of Change) of the 200 period moving average must be greater than 0 for each 1 period, and the Sum function adds up this "True" condition over 20 periods and ensures the result = 20 (Meaning it was true for every period in the 20 periods.

Back to top
  • User Profile
  • View All Posts by User
  • View Thanks
Anne Austin  
#4 Posted : Wednesday, October 26, 2022 2:18:45 AM(UTC)
Anne Austin

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 9/15/2022(UTC)
Posts: 6
Location: Perth

Thank you very much, MS support.

i will try that.

regarding how to detect a 200 day ma that is pointing up for the last month of trading, perhaps it is too restrictive to expect it to go up higher on every one of the 20 trading days.

perhaps I could make the criterion be > 15 or something, rather than = 20?
​​​​​​​

i don't want to knock out any stock candidates just because the moving average didn't increase every day.

Back to top
  • User Profile
  • View All Posts by User
  • View Thanks
MS Support  
#5 Posted : Wednesday, October 26, 2022 2:39:12 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,847

Thanks: 79 times
Was thanked: 148 time(s) in 144 post(s)
Originally Posted by: Anne Austin Go to Quoted Post

Thank you very much, MS support.

i will try that.

regarding how to detect a 200 day ma that is pointing up for the last month of trading, perhaps it is too restrictive to expect it to go up higher on every one of the 20 trading days.

perhaps I could make the criterion be > 15 or something, rather than = 20?

i don't want to knock out any stock candidates just because the moving average didn't increase every day.


Definitely, you could use > 15 instead of = 20 on the end of the formula. If you were planning to use this in the Explorer, you could also leave the Sum portion of the formula off the Filter, and simply add it as a Column formula (and remove the = portion off the end):

Code:
Sum(ROC(Mov(C,200,S),1,$) > 0,20)

That way you aren't restricting your results by that criteria, but you can still Sort your Exploration Report by that Column in order to focus on the securities that saw the 200 Moving Average increasing for the greatest number of periods.

Back to top
  • User Profile
  • View All Posts by User
  • View Thanks
Anne Austin  
#6 Posted : Wednesday, October 26, 2022 9:37:45 PM(UTC)
Anne Austin

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 9/15/2022(UTC)
Posts: 6
Location: Perth

Thank you...I will try that.

the first two bits of the formula worked perfectly. I can now see all stocks sitting above the three averages and with the averages in right order.

Back to top
  • User Profile
  • View All Posts by User
  • View Thanks
Users browsing this topic
Discussions  »  Product and Service Development  »  Formula Assistance  »  How to write a formula to identify a moving average that is trending up in last month
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.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
  • Terms
  • Privacy Statement
  •  
© Copyright 2023 MetaStock. All rights reserved.