Dynamically changing the color of volume bars

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

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

@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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
399 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • 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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top