declare lower;
declare zerobase;
input length = 50;
plot Vol = volume;
plot VolAvg = Average(volume, length);
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.UPTICK);
Vol.DefineColor("Down", Color.DOWNTICK);
Vol.AssignValueColor(if close > close[1] then Vol.color("Up") else if close < close[1] then Vol.color("Down") else GetColor(1));
VolAvg.SetDefaultColor(GetColor(8));
alert( Crosses( Vol, VolAvg, CrossingDirection.ABOVE), concat("Vol has exceeded the ", concat(length, " bar VolAvg")),Alert.ONCE,Sound.Ring);
input length2 = 10;
input paintBars = no;
def isGreen = close > close[length2] and volume > volume[length2];
def isBlue = close > close[length2] and volume < volume[length2];
def isOrange = close < close[length2] and volume < volume[length2];
def isRed = close < close[length2] and volume > volume[length2];
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Green", Color.GREEN);
Vol.DefineColor("Blue", Color.BLUE);
Vol.DefineColor("Orange", Color.ORANGE);
Vol.DefineColor("Red", Color.RED);
Vol.AssignValueColor(if isGreen then Vol.color("Green") else if isBlue then Vol.color("Blue") else if isOrange then Vol.color("Orange") else if isRed then Vol.color("Red") else Color.LIGHT_GRAY);
DefineGlobalColor("Green", Color.GREEN);
DefineGlobalColor("Blue", Color.BLUE);
DefineGlobalColor("Orange", Color.ORANGE);
DefineGlobalColor("Red", Color.RED);
AssignPriceColor(if !paintBars then Color.CURRENT else if isGreen then globalColor("Green") else if isBlue then globalColor("Blue") else if isOrange then globalColor("Orange") else if isRed then globalColor("Red") else Color.LIGHT_GRAY);
plot scan = volume > VolAvg and sum(isGreen, 2) >= 2;