Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,927
Thanks: 85 times Was thanked: 154 time(s) in 150 post(s)

Originally Posted by: Anne Austin 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.
