Enhancing TradingView Charts with Pine Script Bar Colors
Ever find yourself staring at a TradingView chart wondering why all the bars look the same? I mean, there's all this price action happening, but everything just looks like... well, regular candlesticks. That's where coloring your bars comes in handy.

What's Bar Coloring All About?
So basically, Pine Script lets you change the color of your candlesticks based on whatever conditions you set up. Think of it like highlighting important parts of a document, except you're highlighting price bars that meet certain criteria.
The function that does this magic is called barcolor()
. Pretty straightforward name, right?
How barcolor()
Works
Here's what you can mess around with:
- Color: Pick whatever color you want - red, green, purple, doesn't matter
- Offset: Shifts the coloring to previous bars (honestly, I rarely use this)
- Editable: Whether people can change your colors in the settings later
- Show Last: How many recent bars get the color treatment
- Title: Just a label for your color scheme
- Display: Controls where the colors show up

Here's a Real Example I Actually Use
I've got this simple setup that colors bars based on whether the price is above or below a 14-period moving average. Nothing fancy, but it works:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Pineify
//======================================================================//
// ____ _ _ __ //
// | _ \(_)_ __ ___(_)/ _|_ _ //
// | |_) | | '_ \ / _ \ | |_| | | | //
// | __/| | | | | __/ | _| |_| | //
// |_| |_|_| |_|\___|_|_| \__, | //
// |___/ //
//======================================================================//
//@version=6
indicator('SMA Bar Colors', overlay = true)
sma14 = ta.sma(close, 14)
barcolor(close > sma14 ? color.green : color.red)
plot(sma14)
What this does is paint bars green when the closing price is above the moving average, and red when it's below. Super simple, but now I can glance at my chart and immediately see if we're in bullish or bearish territory relative to that average.
Why I Actually Like This
Look, I'm not gonna pretend this is some game-changing secret. But it does make things easier:
- Less squinting: Instead of analyzing every single candlestick, the colors do some of the work
- Spot trends faster: When you see a bunch of green bars followed by red ones, you know something's changing
- Customize for your style: Set it up however makes sense for how you trade
Things I've Learned
After playing with this for a while:
- Don't go overboard: Too many colors just creates a rainbow mess
- Make colors pop: Use colors that actually contrast with each other and the chart background
- Experiment: Try coloring based on volume spikes, RSI levels, or whatever indicators you actually use
Bar coloring isn't going to turn you into some trading wizard, but it can make your charts way easier to read. And honestly, anything that makes chart analysis less of a headache is worth trying. Give it a shot and see if it clicks for you.