Skip to main content

How to Change Candle Colors in Pine Script (It's Easier Than You Think!)

· 5 min read

Ever looked at your TradingView charts and thought, "Man, these candles all look the same"? I totally get it. When you're staring at hundreds of candles trying to spot patterns, having them change colors based on what's actually happening can be a game-changer.

Today I'm going to show you how to make your candles change colors in Pine Script. We'll start with a simple example using volume (because let's be honest, volume tells us a lot about what's really going on), but once you get the hang of it, you can make them change based on pretty much anything.

Changing Candle Color in Pine Script

The Basics (Don't Worry, It's Not Rocket Science)

Before we jump into the fun stuff, let me quickly explain what we're working with. Pine Script is TradingView's programming language for creating custom indicators. Think of it as a way to tell your charts, "Hey, when this happens, do that."

The cool thing about changing candle colors is that it's actually one of the simpler things you can do in Pine Script. You're basically saying, "If this condition is true, make the candle this color. If that condition is true, make it that color."

Why Volume? Because It Matters

The Best Pine Script Generator

I chose volume for this example because it's one of those things that can really tell you what's happening behind the scenes. You know how sometimes a stock moves up on barely any volume? That's usually not as meaningful as when it moves up with tons of volume backing it.

So here's what we're going to do: we'll make candles change colors based on how much volume is behind them. High volume with price going up? Green. High volume with price going down? Red. Medium volume? Yellow. Low volume? We'll keep it simple with blue.

The Easier Way (If You Don't Want to Code)

Pineify | Best Pine Script Editor

Look, I'm going to be straight with you - if you're not into coding, there's actually a visual way to do this with Pineify. It's like having a point-and-click interface for Pine Script. You can set up all these color changes without writing a single line of code.

Here's why some people prefer this route:

  • No need to learn Pine Script syntax (though it's honestly not that hard)
  • You can use as many conditions as you want (TradingView's free plan limits you to 3 indicators)
  • Less chance of making typos that break your code
  • Works across different timeframes automatically
Check out what Pineify can do here.

The Code (Copy and Paste This)

But if you want to do it the traditional way (which is totally fine - I actually prefer it sometimes), here's the code:

//@version=5
indicator(title='Volume Candle Colors', shorttitle="VCC", overlay = true)

// These are our volume levels - adjust these based on your asset
lowVol = 30000
highVol = 100000

// Here's where the magic happens
color_volume = if volume >= lowVol and volume < highVol
color.new(color.yellow, 0) // Yellow for medium volume
else if volume > highVol and close > open
color.new(color.green, 0) // Green for high volume + price up
else if volume > highVol and close < open
color.new(color.red, 0) // Red for high volume + price down
else
color.new(color.blue, 0) // Blue for everything else (low volume)

// This actually applies the colors to your candles
barcolor(color_volume, title='Volume Colors')

How This Actually Works

Let me break this down in plain English:

  1. Volume Thresholds: Those lowVol and highVol numbers are like your cutoff points. Anything below 30,000 is "low volume," between 30,000 and 100,000 is "medium," and above 100,000 is "high."

  2. The Logic: The script checks the volume and price action for each candle. If volume is high AND the candle closed higher than it opened (bullish), it goes green. If volume is high AND the candle closed lower (bearish), it goes red.

  3. The Colors: barcolor() is the function that actually changes the candle colors. Pretty straightforward.

Making It Your Own

Here's the thing - those volume numbers (30,000 and 100,000) are just examples. If you're trading crypto, you might need way higher numbers. If you're trading penny stocks, you might need lower ones.

Also, you can totally change the colors. Don't like yellow? Use orange. Want purple candles? Go for it. The color options are: color.red, color.green, color.blue, color.yellow, color.orange, color.purple, color.white, color.black, and more.

A Few Things to Keep in Mind

  • Test it first: Don't just slap this on your live trading charts. Try it out on some historical data first to see if it makes sense.
  • Adjust the numbers: Seriously, those volume thresholds need to match what you're trading.
  • Combine with other stuff: This works great alongside your other indicators. It's not meant to replace everything else you're doing.

Wrapping Up

Changing candle colors might seem like a small thing, but it can actually make a big difference in how quickly you spot what's happening in the market. When you can see at a glance which candles had significant volume behind them, it helps you focus on the moves that actually matter.

The code I showed you is just the beginning. Once you get comfortable with this, you can make candles change colors based on RSI levels, moving average crossovers, or pretty much any condition you can think of. The possibilities are endless, and honestly, that's what makes this stuff fun.

Give it a try and see how it changes the way you look at your charts!