Need Help getting scan to work

chewie76

Well-known member
VIP
VIP Enthusiast
I am trying to scan for when "Orange" is true. Or "OrangeScan" is true. The results always say No matching symbols and I know that is not right. Can someone tell me why I'm not getting any results? http://tos.mx/nV3vh6u is the indicator I'm trying to scan for. I'd like to see stocks that show the white dots. If you can help, I'd GREATLY appreciate it! Thanks,
 
Solution
Looks very interesting! Thank you so much!! My scan for Z equals 1 showed no results on the daily, but worked on lower timeframes. Looks like it works! I'll keep monitoring on the daily.

The only other problem with this concept is that you have to change the "OrangeLevel" value as it is the dollar difference between bands. So for NQ it would need to be large vs. a smaller dollar stock it would need to be small. Is there a way to code this so that instead of measuring distance between bands in dollar amount, it can be measured in percentage? That way I can say "OrangeLevel" is when the lines are within 10% of each other? Thanks.
I am trying to scan for when "Orange" is true. Or "OrangeScan" is true. The results always say No matching symbols and I know that is not right. Can someone tell me why I'm not getting any results? http://tos.mx/nV3vh6u is the indicator I'm trying to scan for. I'd like to see stocks that show the white dots. If you can help, I'd GREATLY appreciate it! Thanks,
How odd. Played with it for awhile. But I could not get it to work either :(
 
I am trying to scan for when "Orange" is true. Or "OrangeScan" is true. The results always say No matching symbols and I know that is not right. Can someone tell me why I'm not getting any results? http://tos.mx/nV3vh6u is the indicator I'm trying to scan for. I'd like to see stocks that show the white dots. If you can help, I'd GREATLY appreciate it! Thanks,


is the 3 study below close to what you are looking for ?

------------------

original upper study

Code:
# chewy_chgtoscan_00

#https://usethinkscript.com/threads/need-help-getting-scan-to-work.13651/#post-115972
#Need Help getting scan to work
#chewie76  Dec 9, 2022 #1
#I am trying to scan for when "Orange" is true. Or "OrangeScan" is true. T

#http://tos.mx/nV3vh6u
#ThinkScript_study_20221209_2

#DYNO Intraday

#LinearRegCh100 RegressionDivergence - Trigger Lines - Trend Cross
# From Lizard Indicators Link: https://www.lizardindicators.com/trigger-lines-cross-vs-thrust/
# Line #1 - Fast = LinReg (80)
# Line #2 - Slow = EXPEMA[LinReg (80)]

input displace = 0;
input LinRegLength = 1000;
input EMAlength = 180;
input EMAlength2 = 230;
input ColorOn = no;
input bandsON = yes;

def price = close;


#Definitions
def LinReg = Inertia(price[-displace], LinRegLength);
def EMA_LR = ExpAverage(LinReg[-displace], EMAlength);
def EMA_LR2 = ExpAverage(LinReg[-displace], EMAlength2);
def Body = (open + close)/2;

# Defining Long/Short Filters (these instructions determine entries / exits)
# Entry Requirements
def Long_Entry = close > LinReg and close > EMA_LR and body > LinReg and body > EMA_LR and close > high[1] and body > body[1];
# LinReg > LinReg[1] and
def Long_Stay_In = close > LinReg and close > EMA_LR;
def Long_Exit = (close < LinReg or close < EMA_LR) or Long_Stay_In == 0;
def Long_State = If Long_Entry then 1 else if Long_Exit then 0 else Long_State[1];
def Long = Long_State;

# Exit Requirements
def Short_Entry = close < LinReg and close < EMA_LR and body < LinReg and body < EMA_LR and close < low[1] and body < body[1];
# LinReg < LinReg[1] and
def Short_Stay_In = close < LinReg and close < EMA_LR;
def Short_Exit = (close > LinReg or close > EMA_LR) or Short_Stay_In == 0;
def Short_State = If Short_Entry then 1 else if Short_Exit then 0 else Short_State[1];
def Short = Short_State;

#Adding Linear Regression Plots

plot EMA_LinReg = EMA_LR;
EMA_LinReg.SetDefaultColor(CreateColor(255, 215,0));

EMA_LinReg.setlineweight(2);
plot LR = LinReg;
LR.setlineweight(1);
#LR.SetDefaultColor(CreateColor(0, 130, 255));
LR.DefineColor("OverBought", color.red);
LR.DefineColor("OverSold", color.green);
LR.DefineColor("Normal", color.white);
LR.AssignValueColor(if LR < EMA_LinReg then LR.Color("OverBought") else if LR > EMA_LINREG then LR.Color("OverSold") else LR.Color("Normal"));

# Coloring Bars
AssignPriceColor(if ColorON and Long_State then Color.GREEN else if ColorON and Short_State then Color.RED else Color.current);

DefineGlobalColor("Bullish", Color.Green);
DefineGlobalColor("Bearish", Color.Red);
DefineGlobalColor("Bullish2", Color.dark_Green);
DefineGlobalColor("Bearish2", Color.dark_Red);
AddCloud(EMA_LR, LinReg, GlobalColor("Bearish"), GlobalColor("Bullish"));
AddCloud(EMA_LR2,EMA_LR, GlobalColor("Bearish2"), GlobalColor("Bullish2"));

# End


#Regression Bands

input deviations = 2.600;  #set your deviation units here.
input length = 1000; #set your channel lookback period here.

def stdDeviation = StDevAll(price, length);
plot UpCloud = if bandson then EMA_LinReg + deviations * stdDeviation else double.nan;
UpCloud.SetDefaultColor(Color.red);
plot DnCloud = if bandson then EMA_LinReg - deviations * stdDeviation else double.nan;
DnCloud.SetDefaultColor(Color.green);
plot MiddleLine = if bandson then EMA_LinReg else double.nan;
Middleline.SetDefaultColor(Color.yellow);
DefineGlobalColor("Bullish", Color.green);
DefineGlobalColor("Bearish", Color.RED);

#BB

input Num_Dev_Dn = -1.68;
input Num_Dev_up = 1.68;
input length1 = 10;
input BB = yes;
input OrangeLevel = 9;

def expDev = ExpAverage(AbsValue(EMA_LinReg - close), length1);

plot UpperBand2 = if BB then EMA_LinReg + Num_Dev_up * expDev else double.nan;
UpperBand2.SetDefaultColor(Color.dark_orange);
UpperBand2.setlineweight(2);
plot lowerBand2 = if BB then EMA_LinReg + Num_Dev_dn * expDev else double.nan;
lowerBand2.SetDefaultColor(Color.dark_orange);
lowerBand2.setlineweight(2);

def BBDistance = if BB and UpperBand2 - LowerBand2 < OrangeLevel then Upperband2 else double.nan;
def BBDistanceL = if BB and UpperBand2 - LowerBand2 < OrangeLevel then Lowerband2 else double.nan;
plot Orange = BBDistance;
plot OrangeL = BBDistanceL;
plot OrangeScan = if BBDistance then 1 else 0;
OrangeScan.Hide();
Orange.SetDefaultColor(Color.white);
Orange.SetPaintingStrategy(PaintingSTrategy.points);
Orange.setlineweight(5);
OrangeL.SetDefaultColor(Color.white);
OrangeL.SetPaintingStrategy(PaintingSTrategy.points);
OrangeL.setlineweight(5);


------------------------


i disabled all of the plots and replaced some with def.
the orange formula isn't a boolean value, it is a price value.
that comes from this,
def BBDistance = if BB and UpperBand2 - LowerBand2 < OrangeLevel then Upperband2 else double.nan;


is this close to what you are looking for ?

i made this lower study,
copied the condition from the bbdistance formula, and plotted it,
to have a 1 or 0 value.

def cond = (BB and (UpperBand2 - LowerBand2) < OrangeLevel);
plot z = cond;


Code:
# chewy_chgtoscan_00b_lower

#https://usethinkscript.com/threads/need-help-getting-scan-to-work.13651/#post-115972
#Need Help getting scan to work
#chewie76  Dec 9, 2022 #1
#I am trying to scan for when "Orange" is true. Or "OrangeScan" is true. T


#http://tos.mx/nV3vh6u
#ThinkScript_study_20221209_2

declare lower;

#DYNO Intraday

#LinearRegCh100 RegressionDivergence - Trigger Lines - Trend Cross
# From Lizard Indicators Link: https://www.lizardindicators.com/trigger-lines-cross-vs-thrust/
# Line #1 - Fast = LinReg (80)
# Line #2 - Slow = EXPEMA[LinReg (80)]

input displace = 0;
input LinRegLength = 1000;
input EMAlength = 180;
input EMAlength2 = 230;
input ColorOn = no;
input bandsON = yes;

def price = close;


#Definitions
def LinReg = Inertia(price[-displace], LinRegLength);
def EMA_LR = ExpAverage(LinReg[-displace], EMAlength);
def EMA_LR2 = ExpAverage(LinReg[-displace], EMAlength2);
def Body = (open + close)/2;

# Defining Long/Short Filters (these instructions determine entries / exits)
# Entry Requirements
def Long_Entry = close > LinReg and close > EMA_LR and body > LinReg and body > EMA_LR and close > high[1] and body > body[1];
# LinReg > LinReg[1] and
def Long_Stay_In = close > LinReg and close > EMA_LR;
def Long_Exit = (close < LinReg or close < EMA_LR) or Long_Stay_In == 0;
def Long_State = If Long_Entry then 1 else if Long_Exit then 0 else Long_State[1];
def Long = Long_State;

# Exit Requirements
def Short_Entry = close < LinReg and close < EMA_LR and body < LinReg and body < EMA_LR and close < low[1] and body < body[1];
# LinReg < LinReg[1] and
def Short_Stay_In = close < LinReg and close < EMA_LR;
def Short_Exit = (close > LinReg or close > EMA_LR) or Short_Stay_In == 0;
def Short_State = If Short_Entry then 1 else if Short_Exit then 0 else Short_State[1];
def Short = Short_State;

#Adding Linear Regression Plots

def EMA_LinReg = EMA_LR;

#plot EMA_LinReg = EMA_LR;
#EMA_LinReg.SetDefaultColor(CreateColor(255, 215,0));

#EMA_LinReg.setlineweight(2);

#plot LR = LinReg;
#LR.setlineweight(1);
##LR.SetDefaultColor(CreateColor(0, 130, 255));
#LR.DefineColor("OverBought", color.red);
#LR.DefineColor("OverSold", color.green);
#LR.DefineColor("Normal", color.white);
#LR.AssignValueColor(if LR < EMA_LinReg then LR.Color("OverBought") else if LR > EMA_LINREG then LR.Color("OverSold") else #LR.Color("Normal"));

# Coloring Bars
#AssignPriceColor(if ColorON and Long_State then Color.GREEN else if ColorON and Short_State then Color.RED else Color.current);

DefineGlobalColor("Bullish", Color.Green);
DefineGlobalColor("Bearish", Color.Red);
DefineGlobalColor("Bullish2", Color.dark_Green);
DefineGlobalColor("Bearish2", Color.dark_Red);
#AddCloud(EMA_LR, LinReg, GlobalColor("Bearish"), GlobalColor("Bullish"));
#AddCloud(EMA_LR2,EMA_LR, GlobalColor("Bearish2"), GlobalColor("Bullish2"));

# End


#Regression Bands

input deviations = 2.600;  #set your deviation units here.
input length = 1000; #set your channel lookback period here.

def stdDeviation = StDevAll(price, length);
#plot UpCloud = if bandson then EMA_LinReg + deviations * stdDeviation else double.nan;
#UpCloud.SetDefaultColor(Color.red);
#plot DnCloud = if bandson then EMA_LinReg - deviations * stdDeviation else double.nan;
#DnCloud.SetDefaultColor(Color.green);
#plot MiddleLine = if bandson then EMA_LinReg else double.nan;
#Middleline.SetDefaultColor(Color.yellow);
DefineGlobalColor("Bullish", Color.green);
DefineGlobalColor("Bearish", Color.RED);

#BB

input Num_Dev_Dn = -1.68;
input Num_Dev_up = 1.68;
input length1 = 10;
input BB = yes;
input OrangeLevel = 9;

def expDev = ExpAverage(AbsValue(EMA_LinReg - close), length1);

def UpperBand2 = if BB then EMA_LinReg + Num_Dev_up * expDev else double.nan;
def lowerBand2 = if BB then EMA_LinReg + Num_Dev_dn * expDev else double.nan;

#plot UpperBand2 = if BB then EMA_LinReg + Num_Dev_up * expDev else double.nan;
#UpperBand2.SetDefaultColor(Color.dark_orange);
#UpperBand2.setlineweight(2);
#plot lowerBand2 = if BB then EMA_LinReg + Num_Dev_dn * expDev else double.nan;
#lowerBand2.SetDefaultColor(Color.dark_orange);
#lowerBand2.setlineweight(2);


# the condition in the bbdistance formula
def cond = (BB and (UpperBand2 - LowerBand2) < OrangeLevel);
plot z = cond;


def BBDistance = if BB and UpperBand2 - LowerBand2 < OrangeLevel then Upperband2 else double.nan;
def BBDistanceL = if BB and UpperBand2 - LowerBand2 < OrangeLevel then Lowerband2 else double.nan;

#plot Orange = BBDistance;
#plot OrangeL = BBDistanceL;
#plot OrangeScan = if BBDistance then 1 else 0;
#OrangeScan.Hide();
#Orange.SetDefaultColor(Color.white);
#Orange.SetPaintingStrategy(PaintingSTrategy.points);
#Orange.setlineweight(5);
#OrangeL.SetDefaultColor(Color.white);
#OrangeL.SetPaintingStrategy(PaintingSTrategy.points);
#OrangeL.setlineweight(5);
#


-----------------------------------

i changed the lower study to a column study (watchlist)
zchewy1
http://tos.mx/i5H7EPq

(i didn't test it as a scan)

it plots 1 or 0. when 1 , the cell is green, else gray.
based on this formula,

def cond = (BB and (UpperBand2 - LowerBand2) < OrangeLevel);

Code:
# zchewy1
# chewy_chgtoscan_00b_lower


#https://usethinkscript.com/threads/need-help-getting-scan-to-work.13651/#post-115972
#Need Help getting scan to work
#chewie76  Dec 9, 2022 #1
#I am trying to scan for when "Orange" is true. Or "OrangeScan" is true. T


#http://tos.mx/nV3vh6u
#ThinkScript_study_20221209_2

#declare lower;

#DYNO Intraday

#LinearRegCh100 RegressionDivergence - Trigger Lines - Trend Cross
# From Lizard Indicators Link: https://www.lizardindicators.com/trigger-lines-cross-vs-thrust/
# Line #1 - Fast = LinReg (80)
# Line #2 - Slow = EXPEMA[LinReg (80)]

input displace = 0;
input LinRegLength = 1000;
input EMAlength = 180;
input EMAlength2 = 230;
input ColorOn = no;
input bandsON = yes;

def price = close;


#Definitions
def LinReg = Inertia(price[-displace], LinRegLength);
def EMA_LR = ExpAverage(LinReg[-displace], EMAlength);
def EMA_LR2 = ExpAverage(LinReg[-displace], EMAlength2);
def Body = (open + close)/2;

# Defining Long/Short Filters (these instructions determine entries / exits)
# Entry Requirements
def Long_Entry = close > LinReg and close > EMA_LR and body > LinReg and body > EMA_LR and close > high[1] and body > body[1];
# LinReg > LinReg[1] and
def Long_Stay_In = close > LinReg and close > EMA_LR;
def Long_Exit = (close < LinReg or close < EMA_LR) or Long_Stay_In == 0;
def Long_State = If Long_Entry then 1 else if Long_Exit then 0 else Long_State[1];
def Long = Long_State;

# Exit Requirements
def Short_Entry = close < LinReg and close < EMA_LR and body < LinReg and body < EMA_LR and close < low[1] and body < body[1];
# LinReg < LinReg[1] and
def Short_Stay_In = close < LinReg and close < EMA_LR;
def Short_Exit = (close > LinReg or close > EMA_LR) or Short_Stay_In == 0;
def Short_State = If Short_Entry then 1 else if Short_Exit then 0 else Short_State[1];
def Short = Short_State;

#Adding Linear Regression Plots

def EMA_LinReg = EMA_LR;

#plot EMA_LinReg = EMA_LR;
#EMA_LinReg.SetDefaultColor(CreateColor(255, 215,0));

#EMA_LinReg.setlineweight(2);

#plot LR = LinReg;
#LR.setlineweight(1);
##LR.SetDefaultColor(CreateColor(0, 130, 255));
#LR.DefineColor("OverBought", color.red);
#LR.DefineColor("OverSold", color.green);
#LR.DefineColor("Normal", color.white);
#LR.AssignValueColor(if LR < EMA_LinReg then LR.Color("OverBought") else if LR > EMA_LINREG then LR.Color("OverSold") else #LR.Color("Normal"));

# Coloring Bars
#AssignPriceColor(if ColorON and Long_State then Color.GREEN else if ColorON and Short_State then Color.RED else Color.current);

DefineGlobalColor("Bullish", Color.Green);
DefineGlobalColor("Bearish", Color.Red);
DefineGlobalColor("Bullish2", Color.dark_Green);
DefineGlobalColor("Bearish2", Color.dark_Red);
#AddCloud(EMA_LR, LinReg, GlobalColor("Bearish"), GlobalColor("Bullish"));
#AddCloud(EMA_LR2,EMA_LR, GlobalColor("Bearish2"), GlobalColor("Bullish2"));

# End


#Regression Bands

input deviations = 2.600;  #set your deviation units here.
input length = 1000; #set your channel lookback period here.

def stdDeviation = StDevAll(price, length);
#plot UpCloud = if bandson then EMA_LinReg + deviations * stdDeviation else double.nan;
#UpCloud.SetDefaultColor(Color.red);
#plot DnCloud = if bandson then EMA_LinReg - deviations * stdDeviation else double.nan;
#DnCloud.SetDefaultColor(Color.green);
#plot MiddleLine = if bandson then EMA_LinReg else double.nan;
#Middleline.SetDefaultColor(Color.yellow);
DefineGlobalColor("Bullish", Color.green);
DefineGlobalColor("Bearish", Color.RED);

#BB

input Num_Dev_Dn = -1.68;
input Num_Dev_up = 1.68;
input length1 = 10;
input BB = yes;
input OrangeLevel = 9;

def expDev = ExpAverage(AbsValue(EMA_LinReg - close), length1);

def UpperBand2 = if BB then EMA_LinReg + Num_Dev_up * expDev else double.nan;
def lowerBand2 = if BB then EMA_LinReg + Num_Dev_dn * expDev else double.nan;

#plot UpperBand2 = if BB then EMA_LinReg + Num_Dev_up * expDev else double.nan;
#UpperBand2.SetDefaultColor(Color.dark_orange);
#UpperBand2.setlineweight(2);
#plot lowerBand2 = if BB then EMA_LinReg + Num_Dev_dn * expDev else double.nan;
#lowerBand2.SetDefaultColor(Color.dark_orange);
#lowerBand2.setlineweight(2);


# the condition in the bbdistance formula
def cond = (BB and (UpperBand2 - LowerBand2) < OrangeLevel);
plot z = cond;
z.setdefaultcolor(color.black);

#def BBDistance = if BB and UpperBand2 - LowerBand2 < OrangeLevel then Upperband2 else double.nan;
#def BBDistanceL = if BB and UpperBand2 - LowerBand2 < OrangeLevel then Lowerband2 else double.nan;

#plot Orange = BBDistance;
#plot OrangeL = BBDistanceL;
#plot OrangeScan = if BBDistance then 1 else 0;
#OrangeScan.Hide();
#Orange.SetDefaultColor(Color.white);
#Orange.SetPaintingStrategy(PaintingSTrategy.points);
#Orange.setlineweight(5);
#OrangeL.SetDefaultColor(Color.white);
#OrangeL.SetPaintingStrategy(PaintingSTrategy.points);
#OrangeL.setlineweight(5);

assignbackgroundcolor( (if cond then color.green else color.gray));
#
 
Looks very interesting! Thank you so much!! My scan for Z equals 1 showed no results on the daily, but worked on lower timeframes. Looks like it works! I'll keep monitoring on the daily.

The only other problem with this concept is that you have to change the "OrangeLevel" value as it is the dollar difference between bands. So for NQ it would need to be large vs. a smaller dollar stock it would need to be small. Is there a way to code this so that instead of measuring distance between bands in dollar amount, it can be measured in percentage? That way I can say "OrangeLevel" is when the lines are within 10% of each other? Thanks.
 
Last edited:
Solution

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
252 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