Scanner to find distance between price and moving average?

  • Thread starter YungTraderFromMontana
  • Start date
Y

YungTraderFromMontana

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

mc01439

Active member
VIP
Warehouse
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).
P is greater than .50 would be the scan.

#start code
# define the percent difference of close - 200SMA

def a = Average(close, 200);
def d = close - a;
plot p = (d / close) * 100;

#end code

This would be the results for the S&P 100.
Watchlist Scanner
Results
SymbolDescriptionSMA Diff
TGTTARGET CORP COM
23.18​
LMTLOCKHEED MARTIN CORP COM
15.94​
NEENEXTERA ENERGY INC COM
14.97​
PGPROCTER & GAMBLE CO COM
14.49​
SOSOUTHERN CO. COM
14.45​
COSTCOSTCO WHOLESALE CORP COM
14.38​
AAPLAPPLE INC COM
14.01​
TAT&T INC COM
13.92​
HDHOME DEPOT INC COM
13.73​
QCOMQUALCOMM INC COM
13.62​
AIGAMER INTL GRP INC COM
13.16​
TXNTEXAS INSTRUMENTS INC COM
12.99​
WMTWALMART INC COM
12.39​
SBUXSTARBUCKS CORP COM
12.11​
MSFTMICROSOFT CORP COM
11.79​
MDTMEDTRONIC PLC COM
11.77​
CHTRCHARTER COMMUNICATIONS INC COM CL A
11.36​
AGNALLERGAN PLC. COM
11.26​
MAMASTERCARD INCORPORATED COM CL A
11.23​
ALLALLSTATE CORP COM
10.89​
DHRDANAHER CORP COM
10.25​
RTNRAYTHEON CO COM
9.88​
MDLZMONDELEZ INTL INC COM CL A
9.81​
NKENIKE INC COM CL B
9.72​
UPSUNITED PARCEL SERVICE INC COM CL B
9.42​
ACNACCENTURE PLC COM
9.01​
VVISA INC COM CL A
8.9​
CMCSACOMCAST CORP COM CL A
8.79​
KOCOCA-COLA CO COM
8.7​
PEPPEPSICO INC COM
8.55​
CELGCELGENE CORP COM
8.13​
GOOGALPHABET INC COM CL C
7.83​
JPMJPMORGAN CHASE & CO. COM
7.71​
GOOGLALPHABET INC COM CL A
7.54​
MCDMCDONALD'S CORPORATION COM
7.48​
DUKDUKE ENERGY CORP COM
7.45​
BKNGBOOKING HOLDINGS INC COM
7.4​
UTXUNITED TECHNOLOGIES CORP COM
7.4​
LOWLOWE'S COMPANIES INC COM
7.24​
USBUS BANCORP COM
7.24​
CCITIGROUP INC COM
6.23​
GDGENERAL DYNAMICS CORP COM
6.22​
BABOEING CO COM
5.65​
COFCAPITAL ONE FINANCIAL CORP COM
5.46​
IBMINTERNATIONAL BUS MACH CORP COM
5.44​
VZVERIZON COMMUNICATIONS COM
5.43​
CLCOLGATE-PALMOLIVE CO COM
5.3​
GSGOLDMAN SACHS GROUP INC COM
5.01​
KMIKINDER MORGAN INC COM
4.94​
ABTABBOTT LABORATORIES COM
4.72​
CVSCVS HEALTH CORPORATION COM
4.36​
HONHONEYWELL INTERNATIONAL INC COM
4.19​
AXPAMERICAN EXPRESS CO COM
4.12​
AMGNAMGEN INC COM
4.09​
MRKMERCK & CO INC COM
4.04​
BMYBRISTOL-MYERS SQUIBB CO COM
3.98​
DISWALT DISNEY COMPANY (THE) COM
3.7​
FBFACEBOOK INC COM CL A
3.03​
BACBANK OF AMERICA CORPORATION COM
2.83​
WFCWELLS FARGO & COMPANY COM
2.74​
INTCINTEL CORP COM
2.64​
METMETLIFE INC COM
2.62​
EXCEXELON CORP COM
2.55​
BLKBLACKROCK INC COM
2.43​
ORCLORACLE CORP COM
1.95​
BRK/BBERKSHIRE HATHAWAY INC COM CL B
1.17​
PYPLPAYPAL HOLDINGS INC COM
0.66​
CVXCHEVRON CORPORATION COM
0.53​
 

Top