Dynamically changing the color of volume bars

lostcoastsurf

New member
Is there a way to dynamically change the color of volume bars? As in changing the color based on volume percentage or other criteria? Or is it only possible to plot a histogram over the top?
 

lostcoastsurf

New member
I couldn't find how to delete this post so as to not clutter up the forum. So here is my solution. I butchered a script from @horserider that places a bright histogram over the volume bars that are 1.7 times higher than the 50 sma average volume. I have a hard time watching volume so I wanted something to brighten volume spikes on my chart.

Code:
input length = 50;
plot VolAvg = Average(volume, length);

VolAvg.SetDefaultColor(GetColor(7));

input type = { default SMP, EXP } ;
#input length1 = 20 ;
input hotPct = 70.0 ;

def ma =
if type == type.SMP then
SimpleMovingAvg(volume, length)
else
MovAvgExponential(volume, length);

plot hv =
if 100 * ((volume / ma)-1 ) >= hotPct then
ma
else
Double.NaN;

hv.SetDefaultColor( Color.MAGENTA);
hv.SetLineWeight(5) ;
hv.SetPaintingStrategy( PaintingStrategy.HISTOGRAM);
 

generic

Active member
@lostcoastsurf Is this what you want?
Code:
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 Vol > 1.7 * VolAvg then color.MAGENTA else if close > close[1] then Vol.color("Up") else if close < close[1] then Vol.color("Down") else GetColor(1));
VolAvg.SetDefaultColor(GetColor(8));
 

Similar threads

Top