Scanner to find distance between price and moving average?


Well-known member
Does anybody have code for a scan that can filter by a stocks distance from a MA? For Example .5% away from 200 SMA (simple moving average).
Last edited by a moderator:


@mc01439 Similar way —Is there a way to get 52 week high and 52 week low within 5% list ?

That will help for my exploration .. long at 52 week high - short at 52 week low


Well-known member
Here is a scan for stocks with a close that is 10% above 50 day EMA. I just ran that scan query on the S&P 500 and found 2 results on a daily agg.

close crosses above ExpAverage(close, 50) * 1.1

freedom Traders

New member
I need help with a script. Hello everyone,i am new to all of this I would like to know if it's possible for someone to help me with an alert on a 10 minute chart or 4hr chart. I need a script that can alert me when price is in a range in between two different Simple moving average for 4-5 bars. Please


New member
Need script code for scan to load into watchlist columns of price on 60 min that is 5% or greater over 50 SMA also same for 30 min SMA ,,another column for 5% or greater over 20 SMA on 60 min and 30 min,,,,my intent is to identify prices extended from 50sma where rsi 3 day show overbought range of 90 or oversold of 20 ,,,thankyou


Active member
@Slickss Just add the column and in the column define your timeframe. Price ix XYZ Percent away from XYZ Moving Average.

Price ix XYZ Percent away from XYZ MovingAverage
#Define Percent In Decimal
def percentvalue = .05;
#Define Moving Average Desired
def ma = simpleMovingAvg(close,50);
def s = ma*percentvalue;
plot scan = absvalue(close - ma) is greater than or equal to s;

Similar threads