Slop of MA line of Joining High Price of last 20 periods

Need help in writing the code of MA line joining the High price of last 20 periods. Idea is to buy stocks which are having slope more than 30 degrees. Don’t know how to find the slope of the MA line. Please guide. Thanks in advance.
Best regards

Heve You tried

LinRegSlope(MA, periods);

??? See here:

Thanks, Mr. Dalmas ,

But how to get the stocks in filter who are making an angle 30 degrees with the horizontal lines.


Well, IMHO You can apply the very same AFL command to the Close (or Avg, or whatever you want) instead of MA. Anyway I feel the issue behind is how to define the periods on which compute the slope. I means, if you do some trials you will find completely different results depending on the value of “periods” you set. But this is Your decision, I suppose based mainly on your trading time-frame, and may be the TS you have in mind.