Scan for difference in percent change vs SPX

ReyHak

Member
HI,

Please help me convert this to a scan, results are displayed as a % on my watch list, I like to be able to scan for example for any stocks that are between 2% and 5%.

Thank you in advance

Code:
# Difference in Percent Change vs SPX
# Select your choice of timeframe above

# current symbol change
def a = (close-close[1])/close[1];

# SPX change
def sym = close("SPX");
def b = (sym-sym[1])/sym[1];

# current symbol change minus SPX change
def c = a-b;

# gives the difference as a percent value
AddLabel(1,AsPercent(c),
         if c > 0 then createcolor(0,204,75)
         else if c == 0 then color.light_gray
         else createcolor(250,90,0));

#end code
 
Last edited by a moderator:
Just pull this up as as your study filter, enter your percent ranges ( 2 and 5 by default) and select "is True"

Code:
# Difference in Percent Change vs SPX
# Select your choice of timeframe above

# WatchlistColumn by ReyHak
# Scan mods by WTF_Dude

input MinPercent = 2;
input MaxPercent = 5;

# current symbol change
def a = (close-close[1])/close[1];

# SPX change
def sym = close("SPX");
def b = (sym-sym[1])/sym[1];

# current symbol change minus SPX change
def c = a-b;

plot target = c <= (MaxPercent/100) and c >= (MinPercent/100);

# gives the difference as a percent value
#AddLabel(1,AsPercent(c),
#if c > 0 then createcolor(0,204,75)
#else if c == 0 then color.light_gray
#else createcolor(250,90,0));

#end code
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

@wtf_dude Quick question please, when I change the period to for example 5 days, the scan also returns stocks that are for example -1% even though my min and max is 2 and 5, do you know why? Bolded section below. Also, you mention to select "True", I do not see that option?

Code:
# Difference in Percent Change vs SPX
# Select your choice of timeframe above

# WatchlistColumn by ReyHak
# Scan mods by WTF_Dude

input MinPercent = 2;
input MaxPercent = 5;

# current symbol change
def a = (close-close[5])/close[5];

# SPX change
def sym = close("SPX");
def b = (sym-sym[5])/sym[5];

# current symbol change minus SPX change
def c = a-b;

plot target = c <= (MaxPercent/100) and c >= (MinPercent/100);

# gives the difference as a percent value
#AddLabel(1,AsPercent(c),
#if c > 0 then createcolor(0,204,75)
#else if c == 0 then color.light_gray
#else createcolor(250,90,0));

#end code
 
Well for the -1%, your search is only looking for things that are up between 2-5% since the close 5 days ago. So it will show up EVEN IF it's down today.If you want to make sure it's positive on the current day you can change the plot line to

plot target = c <= (MaxPercent/100) and c >= (MinPercent/100) and ( close-close[1])>=0 ;

Ok for the "is true", make sure you past this code into create new study on the charts page. You lose the functionality of not having to screw with the code if you just copy and paste it as a custom study on the scan page. It's too easy for things to get screwed up if you ocnstantly change settings through the code itself.
Once you have the study saved. You will load it through study filter, custom, find the study. Leave the entry boxes at 2 and 5. IN THE MIDDLE COLUMN where it says "is greater than" "less than" etc etc. One of the options near the bottom is "is true". Select that and click ok.
 
Hi guys. Today I found one video How to find stock to trade. Is it possible to make similar scanner? I need +/- % From close (to SPY) and % change stock to SPY.

 
Did you see video?+/- % From close gives understand about % change by yesterday.Second is % change between SPY and stock,to understand that stock is “bullish” when the market goes down.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
163 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top