Find Supply/Demand Divergence w $ADSPD and $TICK For ThinkOrSwim

John Thanos

New member
Hi Everyone came across this video that was very interesting. Wondering if anyone could give it a shot to clean this up or make it better. Below is the code. Credit to the owner of this video. Thanks
#TOS Indicators
#Home of the Volatility Box
#More info regarding this indicator here:
#Code written in 2019
#Credit to Ron Wikso for catching $TICK copy/paste error on lines 18 & 19
#Credit to Brent Wilderman for adding code that enables study to work w/ extended hours on and off

declare upper;
declare hide_on_daily;

input showTicks = yes;
input showAD = yes;

def regularSession = secondsFromTime(0930) > 0 && secondsTillTime(1600) > 0;

def hod = if regularSession then if (high > hod[1]) then high else hod[1] else high;
def lod = if regularSession then if (low < lod[1]) then low else lod[1] else low;

def highAD = if regularSession then if (high(symbol="$ADSPD") > highAD[1]) then high(symbol="$ADSPD") else highAD[1] else high(symbol="$ADSPD");
def lowAD = if regularSession then if (low(symbol="$ADSPD") < lowAD[1]) then low(symbol="$ADSPD") else lowAD[1] else low(symbol="$ADSPD");

def highTick = if regularSession then if (high(symbol="$TICK") > highTick[1]) then high(symbol="$TICK") else highTick[1] else high(symbol="$TICK");
def lowTick = if regularSession then if (low(symbol="$TICK") < lowTick[1]) then low(symbol="$TICK") else lowTick[1] else low(symbol="$TICK");

def currentHighAD = high(symbol="$ADSPD");
def currentLowAD = low(symbol="$ADSPD");
def currentHighTick = high(symbol="$TICK");
def currentLowTick = low(symbol="$TICK");

plot ADShortSignal = showAD && high == hod && currentHighAD < highAD;

plot ADLongSignal = showAD && low == lod && currentLowAD > LowAD;

plot TickShortSignal = showTicks && high == hod && currentHighTick < highTick;

plot TickLongSignal = showTicks && low == lod && currentLowTick > lowTick;
Last edited by a moderator:


Staff member
is there a way to scan for $aspd divergence to SPY LONG AND SHORT ?
if you are asking how to scan for the Long and Short Signals in the above script:
  1. copy&paste the above script into a study and name it
  2. go to Scan Hacker, type in the name of your study
  3. choose AdShortSignal true or ADLongSignal is true

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.