# Average Volume Deviation For ThinkOrSwim

#### Pelonsax

##### Active member
VIP
I'm playing around with the idea of volume divergences, so I wanted to see an average of volume deviated from the norm. I couldn't really find anything already scripted, so I made this. So far, I don't have any correlation other than the fact that when volume increases, range and volatility also increase. But it's interesting enough to pursue and share so here you go. Enjoy.

https://tos.mx/l0jtfkw

Code:
``````#-------------------------------
#
# AVERAGE VOLUME DEVIATION
# Author: Ramon DV aka Pelonsax
#
#--------------------------------
declare lower;

input length = 7;
input signalLength = 10;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = yes;

def V = volume;

plot AVD = MovingAverage(averageType, V, length);
plot Signal = MovingAverage(averageType, AVD, signalLength);

plot UpSignal = if AVD crosses above signal then signal else Double.NaN;
plot DownSignal = if AVD crosses below signal then signal else Double.NaN;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

Signal.SetDefaultColor(GetColor(2));

AVD.SetDefaultColor(GetColor(5));
AVD.SetPaintingStrategy(PaintingStrategy.line);
AVD.SetLineWeight(3);

AVD.DefineColor("Above and Up", Color.GREEN);
AVD.DefineColor("Above and Down", Color.DARK_GREEN);
AVD.DefineColor("Below and Down", Color.RED);
AVD.DefineColor("Below and Up", Color.DARK_RED);
AVD.DefineColor("Current", Color.CURRENT);

AVD.AssignValueColor( if AVD > Signal and AVD > AVD[1] then
AVD.Color("Above and Up") else if AVD >= Signal and AVD < AVD[1] then
AVD.Color("Above and Down") else if AVD < Signal  and AVD < AVD[1] then
AVD.Color("Below and Down") else if AVD <= Signal and AVD > AVD[1] then
AVD.Color("Below and Up") else AVD.Color("Current"));``````

Oops! Haha! Forgot to add upsignal and downsignal. I'll get it later. (It's late.)

Oops! Haha! Forgot to add upsignal and downsignal. I'll get it later. (It's late.)
Continue bro -- We all learning -- thanks for sharing

### Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
228 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• 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?