NexusFi: Find Your Edge


Home Menu

 





scan for stocks whose price is X% within MA


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one DaveDoggyDogg with 5 posts (6 thanks)
    2. looks_two neilpat95 with 2 posts (0 thanks)
    3. looks_3 SamTrader1985 with 2 posts (0 thanks)
    4. looks_4 growex with 1 posts (4 thanks)
    1. trending_up 26,822 views
    2. thumb_up 10 thanks given
    3. group 12 followers
    1. forum 18 posts
    2. attach_file 1 attachments




 
Search this Thread

scan for stocks whose price is X% within MA

  #1 (permalink)
fadeyourbets
new york
 
Posts: 1 since Nov 2013
Thanks Given: 0
Thanks Received: 0

hello,

I would like to create a scan that lists all stocks whose price is 5% within their 50DAY SMA.

is there a way to create that sort of screen in TOS?

any help appreciated.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Increase in trading performance by 75%
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
35 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
19 thanks
GFIs1 1 DAX trade per day journal
16 thanks
Spoo-nalysis ES e-mini futures S&P 500
14 thanks
  #2 (permalink)
 growex 
Trubchevsk
 
Experience: Beginner
Platform: tos
Trading: stocks
Posts: 61 since May 2011
Thanks Given: 40
Thanks Received: 79

Open Scan Tab and click on Add Study Filter button.
On the left hand side there is a dropbox with a Criteria caption, open it and choose Custom field (the one on the bottom of dropdown list)
Scanner Custom Filter window will appear. Open ThinkscriptEditor tab.
Delete ADXCrossover() line.

Paste the following code into thinkscript editor:

def ma = SimpleMovingAvg(close,50);
def s = ma*0.05;
plot scan = absvalue(close - ma) is less than or equal to s;

Choose the aggregation period you want to scan on.
Click OK

Now click Save Scan Query so you can load this scan later

Follow me on Twitter Reply With Quote
  #3 (permalink)
Reunionman
Sacramento
 
Posts: 1 since May 2019
Thanks Given: 1
Thanks Received: 0


Regarding this reply:

def ma = SimpleMovingAvg(close,50);
def s = ma*0.05;
plot scan = absvalue(close - ma) is less than or equal to s;

I noticed on some Think or Swim study filters, there are drop down boxes.
Is it possible to create our own drop down box for the Simple Moving Average (say 10, 13,20,30,50,200)
and for the Percent (.05, .10, .15, .20 and so on)?

I did copy and paste above code and it works great. Before I make a scan for each one that I want and change the numbers, thought I would ask first?

Reunionman

Reply With Quote
  #4 (permalink)
 kjhosken 
Seattle, WA/USA
 
Experience: Intermediate
Platform: TOS, TS
Trading: Forex, crude
Posts: 96 since Sep 2016
Thanks Given: 7
Thanks Received: 35

Add this:

input percent = 0.05;
and change '0.05' to 'percent'

for the MA:
input length = 50;

and change 50 to length
this will allow you to input any number. If you'd prefer a drop down it would be

input percent = {default 0.05, 0.10, etc.....};

Same for the MA.

Reunionman View Post
Regarding this reply:

def ma = SimpleMovingAvg(close,50);
def s = ma*0.05;
plot scan = absvalue(close - ma) is less than or equal to s;

I noticed on some Think or Swim study filters, there are drop down boxes.
Is it possible to create our own drop down box for the Simple Moving Average (say 10, 13,20,30,50,200)
and for the Percent (.05, .10, .15, .20 and so on)?

I did copy and paste above code and it works great. Before I make a scan for each one that I want and change the numbers, thought I would ask first?

Reunionman


Follow me on Twitter Reply With Quote
  #5 (permalink)
jym shoe
Bald Knob, Ar
 
Posts: 1 since Jun 2019
Thanks Given: 1
Thanks Received: 0

Hi!, Thanks for your help!... How would I filter for stocks that are (last price) equal to or greater than 10% above the 30 SMA?

Thanks in advance,

Jym Shoe

Reply With Quote
  #6 (permalink)
DaveDoggyDogg
Los Angeles,CA USA
 
Posts: 16 since Mar 2017
Thanks Given: 0
Thanks Received: 7


jym shoe View Post
Hi!, Thanks for your help!... How would I filter for stocks that are (last price) equal to or greater than 10% above the 30 SMA?

Thanks in advance,

Jym Shoe

Symbols that the PRICE is 10% AWAY FROM the 30SMA

 
Code
def ma = SimpleMovingAvg(close,30);
def percent = ma*0.10;
plot scan = absvalue(close - ma) is greater than or equal to percent;
or short version (both are the same just coded differently)

 
Code
def ma = SimpleMovingAvg(close,30);
def percent = ma*0.10;
plot scan = absvalue(close - ma) >= percent;
-------------------------------------------------------------------------------
For the exact moving average scanner scan you want it is already built into TOS "jym shoe"
no custom thinkscript needed do what you want, just do the following in thinkorswim :

**STOCK HACKER > ADD STUDY FILTER>POPULAR STUDIES>MOVINGAVERAGE_SCAN>
select
**The Close is atleast 10% above the 30 period Simple moving average

(you can choose ema ( exponential ) sma ( simple ) weighted wilders and hull )

Reply With Quote
Thanked by:
  #7 (permalink)
codeblue702
Las vegas
 
Posts: 1 since Dec 2019
Thanks Given: 0
Thanks Received: 0

Hi, Are you able to add the condition that you only want to see stocks that have a higher 50 SMA than 200 SMA?

Reply With Quote
  #8 (permalink)
DaveDoggyDogg
Los Angeles,CA USA
 
Posts: 16 since Mar 2017
Thanks Given: 0
Thanks Received: 7


codeblue702 View Post
Hi, Are you able to add the condition that you only want to see stocks that have a higher 50 SMA than 200 SMA?

 
Code
close is greater than or equal to SimpleMovingAvg("length" = 200)."SMA" and close is greater than or equal to SimpleMovingAvg("length" = 50)."SMA"

Reply With Quote
  #9 (permalink)
 Nostar123 
Atlanta
 
Experience: Beginner
Platform: Ib
Trading: Es
Posts: 19 since Oct 2014
Thanks Given: 108
Thanks Received: 17

Is there a way to filter out stocks that are above the 30 SMA by 10% to 15 percent?

I am looking for a code that can filter out stocks that are at least 10% above the 30 SMA but not exceeding 15%

Reply With Quote
  #10 (permalink)
DaveDoggyDogg
Los Angeles,CA USA
 
Posts: 16 since Mar 2017
Thanks Given: 0
Thanks Received: 7



Nostar123 View Post
Is there a way to filter out stocks that are above the 30 SMA by 10% to 15 percent?

I am looking for a code that can filter out stocks that are at least 10% above the 30 SMA but not exceeding 15%

 
Code
def ma = SimpleMovingAvg(close,30);
def percent = ma*0.10;
def percent2 = ma*0.15;
plot scan = absvalue(close - ma) is greater than or equal to percent and absvalue(close - ma) is less than or equal to percent2 and close is greater than SimpleMovingAvg("length" = 30)."SMA" ;

Reply With Quote
Thanked by:




Last Updated on November 20, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts