Approaching the 200 day moving average


Category:
0
0

Hello there Mr. Hahn,

I’m looking to create a simple scan that shows me stocks approaching their 200 day SMA from above or below. Maybe something like the price is 1 or 2 percent away from the 200 SMA from either direction. It seems simple enough but I know nothing about scripting. Any info would be greatly appreciated. Thanks in advance.

Marked as spam
Posted by (Questions: 2, Answers: 0)
Asked on March 4, 2019 2:08 pm
343 views
0
Private answer

I haven’t tested it. But I’m pretty sure this should do the trick:

input lengthOne = 200;
input maTypeOne = AverageType.SIMPLE;
input priceOne = close;
input percentMax = 2.0;
input percentMin = 1.0;
def maOne = MovingAverage(maTypeOne, priceOne, lengthOne);
def approachingAbove = close <= maOne * (1 + percentMax * 0.01) or close >= maOne * (1 - percentMin * 0.01);
def approachingBelow = close >= maOne * (1 - percentMax * 0.01) or close <= maOne * (1 + percentMin * 0.01);
plot scan = approachingAbove or approachingBelow;

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on April 5, 2019 8:15 am