Scan for difference in percent change vs SPX

ReyHak

New 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:

wtf_dude

Active member
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
 

ReyHak

New member
@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
 

wtf_dude

Active member
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.
 

Valeriy

New member
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.

 

wtf_dude

Active member
Not sure what you mean. You want the changes of both, but then what? What are you scanning for? Both of them move a certain amount?
 

Valeriy

New member
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

Top