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
Ruby:
#TOS Indicators
#Home of the Volatility Box
#More info regarding this indicator here: tosindicators.com/supply-demand-edge
#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;
ADShortSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
ADShortSignal.SetDefaultColor(Color.WHITE);
ADShortSignal.SetLineWeight(1);

plot ADLongSignal = showAD && low == lod && currentLowAD > LowAD;
ADLongSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ADLongSignal.SetDefaultColor(Color.WHITE);
ADLongSignal.SetLineWeight(1);

plot TickShortSignal = showTicks && high == hod && currentHighTick < highTick;
TickShortSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
TickShortSignal.SetDefaultColor(Color.RED);
TickShortSignal.SetLineWeight(2);

plot TickLongSignal = showTicks && low == lod && currentLowTick > lowTick;
TickLongSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
TickLongSignal.SetDefaultColor(Color.LIGHT_GREEN);
TickLongSignal.SetLineWeight(2);
 
Last edited by a moderator:

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

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
 
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
Ruby:
#TOS Indicators
#Home of the Volatility Box
#More info regarding this indicator here: tosindicators.com/supply-demand-edge
#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;
ADShortSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
ADShortSignal.SetDefaultColor(Color.WHITE);
ADShortSignal.SetLineWeight(1);

plot ADLongSignal = showAD && low == lod && currentLowAD > LowAD;
ADLongSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ADLongSignal.SetDefaultColor(Color.WHITE);
ADLongSignal.SetLineWeight(1);

plot TickShortSignal = showTicks && high == hod && currentHighTick < highTick;
TickShortSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
TickShortSignal.SetDefaultColor(Color.RED);
TickShortSignal.SetLineWeight(2);

plot TickLongSignal = showTicks && low == lod && currentLowTick > lowTick;
TickLongSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
TickLongSignal.SetDefaultColor(Color.LIGHT_GREEN);
TickLongSignal.SetLineWeight(2);
I think this script has merit for sure. I am happy to help any way I can. JT, have you had any luck so far since I am a little late to the party?
 
I think this script has merit for sure. I am happy to help any way I can. JT, have you had any luck so far since I am a little late to the party?

Did you know that by clicking on a member's name, you can easily check when they were last seen on the uTS forum? It's a great way to keep track of who's been around recently, and who hasn't. Speaking of which, it looks like @John Thanos is no longer active. :(
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
187 Online
Create Post

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