Custom Scan for Watchlist based on VWAP, 20EMA & 9EMA crossover

TOS009

New member
Hello,
First post here. No experience whatsoever on Thinkscript.
I'd like to create a watchlist of stocks( trading on 2 min chart), based on the following criteria:
  • Price(LAST) between $5 and $250
  • Today Volume(in shares) > 300,000
  • Float > 10M
  • Relative Volume >=2
  • ATR >= $0.5
  • Change %(since previous day's close) max -2% (ie stocks that are trading atleast 2% below previous close)
  • Price(LAST) < VWAP
  • Price(LAST) < 20 EMA
  • Price(LAST) just crossed below 9EMA, but not more than 0.1% away from 9EMA
Is this possible and if yes, can someone pls point to code that can perform a similar scan. I'll attempt to tweak if possible, but any guidance is much appreciated.

I have alerts setup for price crossing below 9EMA and 9EMA crossing below 20EMA etc..,but couldnt find a way to setup the above custom scan for the Watchlist.

Thanks much
 
Last edited:
Solution
Hello,
First post here. No experience whatsoever on Thinkscript.
I'd like to create a watchlist of stocks( trading on 2 min chart), based on the following criteria:
  • Price(LAST) between $5 and $250
  • Today Volume(in shares) > 300,000
  • Float > 10M
  • Relative Volume >=2
  • ATR >= $0.5
  • Change %(since previous day's close) max -2% (ie stocks that are trading atleast 2% below previous close)
  • Price(LAST) < VWAP
  • Price(LAST) < 20 EMA
  • Price(LAST) just crossed below 9EMA, but not more than 0.1% away from 9EMA
Is this possible and if yes, can someone pls point to code that can perform a similar scan. I'll attempt to tweak if possible, but any guidance is much appreciated.

I have alerts setup for price crossing...
Hello,
First post here. No experience whatsoever on Thinkscript.
I'd like to create a watchlist of stocks( trading on 2 min chart), based on the following criteria:
  • Price(LAST) between $5 and $250
  • Today Volume(in shares) > 300,000
  • Float > 10M
  • Relative Volume >=2
  • ATR >= $0.5
  • Change %(since previous day's close) max -2% (ie stocks that are trading atleast 2% below previous close)
  • Price(LAST) < VWAP
  • Price(LAST) < 20 EMA
  • Price(LAST) just crossed below 9EMA, but not more than 0.1% away from 9EMA
Is this possible and if yes, can someone pls point to code that can perform a similar scan. I'll attempt to tweak if possible, but any guidance is much appreciated.

I have alerts setup for price crossing below 9EMA and 9EMA crossing below 20EMA etc..,but couldnt find a way to setup the above custom scan for the Watchlist.

Thanks much

i know you asked for a scan, but with 9 formulas, it might be best to start with a chart study, to be able to view the inputs and verify the output.

here is a lower chart study, with 8 of the 9 formulas.
i don't know how to do float.

i have never seen a true output from this, so i think some of your formula parameters may need to be changed.

i set it up to be easily converted to a scan.
make a copy and delete everything after this line,
plot t = trigger;
to use the study as a scan.

Ruby:
# vol_atr_vwap_ema_00_dots_00c


# a lower version for testing, that draws rows of dots


# usr Q list VWAP, 20EMA & 9EMA crossover
#https://usethinkscript.com/threads/custom-scan-for-watchlist-based-on-vwap-20ema-9ema-crossover.9234/
#Custom Scan for Watchlist based on VWAP, 20EMA & 9EMA crossover
#TOS009 
# Start dateDec 11, 2021 

#First post here. No experience whatsoever on Thinkscript.
#I'd like to create a watchlist of stocks( trading on 2 min chart), based on the following criteria:

#Price(LAST) between $5 and $250
#Today Volume(in shares) > 300,000
#Float > 10M
#Relative Volume >=2
#ATR >= $0.5
#Change %(since previous day's close) max -2% (ie stocks that are trading atleast 2% below previous close)
#Price(LAST) < VWAP
#Price(LAST) < 20 EMA
#Price(LAST) just crossed below 9EMA, but not more than 0.1% away from 9EMA

#Is this possible and if yes, can someone pls point to code that can perform a similar scan. I'll attempt to tweak if possible, but any guidance is much appreciated.

#I have alerts setup for price crossing below 9EMA and 9EMA crossing below 20EMA etc..,but couldnt find a way to setup the above custom scan for the Watchlist.

#----------------------

declare lower;

# 2 min chart
def na = Double.NaN;
def c = !isnan(close);

# ------------------------------------------------

# 1 Price(LAST) between $5 and $250
def pricehi = 250;
def pricelo = 5;
def isprice = ( close >= pricelo and close <= pricehi);

# 2 Today Volume(in shares) > 300,000
def newday = GetDay() <> GetDay()[1];
def dvol = if newday then 0 else volume + dvol[1];
def volmin = 300000;
def isvol = ( dvol > volmin);

# 3 Float > 10M
# cant do float
def float = 1;

# 4 Relative Volume >=2
input rel_vol_factor = 2; 
# https://usethinkscript.com/threads/rvol-relative-volume-indicator-watchlist-for-thinkorswim.1014/#post-8511
# post4
input length = 21;
input offset = 1;
def ADV = Average(volume, length)[offset];
def rVol = volume /ADV;
def isrvol = rvol >= rel_vol_factor;

# 5 ATR >= $0.5
def atr_min = 0.5;
input atr_length = 14;
input averageType = AverageType.WILDERS;
def atr1 = MovingAverage(averageType, TrueRange(high, close, low), atr_length);
def isatr = atr1 > atr_min;

# 6 Change %(since previous day's close) max -2% (ie stocks that are trading atleast 2% below previous close)
def per1 = 0.02;
def prevday = if GetDay() <> GetDay()[-1] then close else prevday[1];
def islow = (close <= (prevday * (1 - per1)));

# 7 Price(LAST) < VWAP
def isvwap = (close < vwap);

# 8 Price(LAST) < 20 EMA
def ema1len = 20;
def ema20 = ExpAverage(close, ema1len);
def isema20 = (close < ema20);

# 9 Price(LAST) just crossed below 9EMA, but not more than 0.1% away from 9EMA
def ema2len = 9;
def ema9 = ExpAverage(close, ema2len);
def emaper = 0.001;
def ema9lo = (ema9 - (emaper * ema9));
def ema9xdwn = ((close crosses below ema9) and ( close > ema9lo));

#-----------------------  9 inputs
def trigger =
    isprice
and isvol
and float
and isrvol
and isatr
and islow
and isvwap
and isema20
and ema9xdwn;

# this will be 1 or 0 , true or false
plot t = trigger;

#----------------------------------------------------
# if you want to try the above code as a scan study, delete every line after this line 
#----------------------------------------------------

# output above 0
# 9 inputs below 0

# last bar
def lastbar = !IsNaN(close[0]) and IsNaN(close[-1]);
def cls2 = if lastbar then close else cls2[1];

def x = 4;
def afterbar = !IsNaN(close[x + 1]) and IsNaN(close[x]);

input show_dot_legend = no;
AddChartBubble(show_dot_legend and afterbar, 2, 
" trigger "
+ "\n1 " + "isprice"
+ "\n2 " + "isvol"
+ "\n3 " + "float"
+ "\n4 " + "isrvol"
+ "\n5 " + "isatr"
+ "\n6 " + "islow"
+ "\n7 " + "isvwap"
+ "\n8 " + "isema20"
+ "\n9 " + "ema9xdwn"
, Color.YELLOW, no);

# ----------------------------------

# plot rows of dots for each signal

# trigger
plot o1 = if IsNaN(close) then na else 1;
o1.SetPaintingStrategy(PaintingStrategy.SQUARES);
o1.AssignValueColor(if trigger then Color.GREEN else Color.dark_GRAY);
o1.SetLineWeight(1);
o1.HideBubble();

plot z = if c then 0 else na;
z.SetDefaultColor(Color.GRAY);
z.SetDefaultColor(Color.GRAY);
z.HideBubble();

# ----------------------------------

# 1 isprice
plot i1 = if IsNaN(close) then na else -1;
i1.SetPaintingStrategy(PaintingStrategy.POINTS);
i1.AssignValueColor(if isprice then Color.GREEN else Color.RED);
i1.SetLineWeight(1);
i1.HideBubble();

# 2 isvol
plot i2 = if IsNaN(close) then na else -2;
i2.SetPaintingStrategy(PaintingStrategy.POINTS);
i2.AssignValueColor(if isvol then Color.GREEN else Color.RED);
i2.SetLineWeight(1);
i2.HideBubble();

# 3 float
plot i3 = if IsNaN(close) then na else -3;
i3.SetPaintingStrategy(PaintingStrategy.POINTS);
#i3.AssignValueColor(if float then color.green else color.red);
i3.AssignValueColor(if float then Color.MAGENTA else Color.RED);
i3.SetLineWeight(1);
i3.HideBubble();

# 4 isrvol
plot i4 = if IsNaN(close) then na else -4;
i4.SetPaintingStrategy(PaintingStrategy.POINTS);
i4.AssignValueColor(if isrvol then Color.GREEN else Color.RED);
i4.SetLineWeight(1);
i4.HideBubble();

# 5 isatr
plot i5 = if IsNaN(close) then na else -5;
i5.SetPaintingStrategy(PaintingStrategy.POINTS);
i5.AssignValueColor(if isatr then Color.GREEN else Color.RED);
i5.SetLineWeight(1);
i5.HideBubble();

# 6 islow
plot i6 = if IsNaN(close) then na else -6;
i6.SetPaintingStrategy(PaintingStrategy.POINTS);
i6.AssignValueColor(if islow then Color.GREEN else Color.RED);
i6.SetLineWeight(1);
i6.HideBubble();

# 7 isvwap
plot i7 = if IsNaN(close) then na else -7;
i7.SetPaintingStrategy(PaintingStrategy.POINTS);
i7.AssignValueColor(if isvwap then Color.GREEN else Color.RED);
i7.SetLineWeight(1);
i7.HideBubble();

# 8 isema20
plot i8 = if IsNaN(close) then na else -8;
i8.SetPaintingStrategy(PaintingStrategy.POINTS);
i8.AssignValueColor(if isema20 then Color.GREEN else Color.RED);
i8.SetLineWeight(1);
i8.HideBubble();

# 9 ema9xdwn;
plot i9 = if IsNaN(close) then na else -9;
i9.SetPaintingStrategy(PaintingStrategy.POINTS);
i9.AssignValueColor(if ema9xdwn then Color.GREEN else Color.RED);
i9.SetLineWeight(1);
i9.HideBubble();

# ---------------------------------
# 4
input test_rvol = no;
AddChartBubble(test_rvol and c, 1.5, "V " + volume + "\nA " + floor(adv)  + "\nR " + round(rvol, 2)  + "\n" + isrvol, ( if isrvol then Color.CYAN else Color.GRAY), yes);

# 5
input test_atr = no;
AddChartBubble(test_atr and c, 1.5, atr1 , ( if isatr then Color.CYAN else Color.GRAY), yes);

# 6
input test_low = no;
AddChartBubble(test_low and c, 1.5, per1 + "\n" + "P " + prevday + "\nC " + round(close, 2), ( if islow then Color.CYAN else Color.GRAY), yes);

# 7
input test_vwap = no;
AddChartBubble(test_vwap and c, 1.5, "V " + vwap + "\nC " + round(close, 2), ( if isvwap then Color.CYAN else Color.GRAY), yes);

# 8
input test_ema20 = no;
AddChartBubble(test_ema20 and c, 1.5, "E " + ema20 + "\nC " + round(close, 2), ( if isema20 then Color.CYAN else Color.GRAY), yes);

input test_emax = no;
AddChartBubble(test_emax and c, 1.5, "E9 " + ema9 + "\nC " + round(close, 2) + "\n" + ema9lo + "\n" +  ema9xdwn, ( if  ema9xdwn then Color.CYAN else Color.GRAY), yes);

#------------------------------------------

#https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Tech-Analysis/ExpAverage
#https://usethinkscript.com/threads/rvol-relative-volume-indicator-watchlist-for-thinkorswim.1014/
#

lower study
top row , gray dots, is the trigger output. i have never seen any green output dots.
the 9 rows of dots under the line at 0, are the inputs.
the 3rd row is for float. it is set to 1, because i don't know how to calculate float.
Xuu1IGX.jpg
 
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
578 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