I added volume average to the Mixed Volume indicator to plot the average Buy and average Sell volume. Would it be possible to combine the Buy and Sell averages into one line that changes colors based on whether the dominant average is a Buy or Sell?
Code:
declare on_volume;
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V*(C-L)/(H-L);
def Selling = V*(H-C)/(H-L);
# Selling Volume
Plot SV = selling;
SV.setPaintingStrategy(PaintingStrategy.Histogram);
SV.SetDefaultColor(Color.Red);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(5);
# Buying Volume
# Plot BV = Buying;
# Note that Selling + Buying Volume = Volume.
Plot BV = volume;
BV.setPaintingStrategy(PaintingStrategy.Histogram);
BV.SetDefaultColor(Color.Dark_Green);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(5);
input length = 50;
plot VolAvg = Average(sv, length);
plot VolAvg2 = Average(bv, length);
VolAvg.SetDefaultColor(GetColor(8));
VolAvg.SetDefaultColor(GetColor(7));