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
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"));