How to Change Candle Color in Pine Script
Use Pine Script's barcolor() function to color the chart's existing bars according to a condition. TradingView's bar-coloring documentation notes that it affects the main chart bars even when the script itself uses a separate pane.

Define What Each Color Means
The example below groups reported volume into two adjustable thresholds and uses the candle's close versus open for direction. The thresholds are arbitrary teaching values. They are not measurements of typical AAPL, crypto or forex volume, and the colors do not predict the next move.
//@version=6
indicator("Volume Candle Colors", shorttitle="VCC", overlay=true)
lowVol = input.float(30000, "Lower volume threshold", minval=0)
highVol = input.float(100000, "Higher volume threshold", minval=0)
if highVol <= lowVol
runtime.error("Higher threshold must exceed lower threshold.")
color barTint = na
if not na(volume)
if volume < lowVol
barTint := color.blue
else if volume < highVol
barTint := color.yellow
else if close > open
barTint := color.green
else if close < open
barTint := color.red
else
barTint := color.gray
barcolor(barTint, title="Volume-Based Colors")
Inspect the Boundary Cases
| Condition | Color |
|---|---|
| Volume below the lower threshold | Blue |
| Volume at the lower threshold but below the higher threshold | Yellow |
| Volume at or above the higher threshold, close above open | Green |
| Volume at or above the higher threshold, close below open | Red |
| High-volume doji | Gray |
| Missing volume | No color override |
Using “at or above” avoids an unclassified boundary at the upper threshold. The explicit doji branch also avoids describing an unchanged candle as low volume.
Calibrate to the Actual Feed
Inspect the volume field for the symbol, venue, interval and session you use. Providers can report different volume types, including tick volume or no volume. A raw threshold cannot be transferred from shares to contracts or a crypto pair without checking its units.
On an unfinished bar, both volume and the close can change, so the displayed color can change too. That is expected for this example. If you require a close-time decision, define and test that rule separately.
Add and Troubleshoot the Script
Save the complete source in Pine Editor and add it to the chart. Check compilation, script visibility and whether reported volume reaches the configured ranges. Hide other bar-coloring scripts temporarily if their output makes the result unclear.
overlay=true is used here for a familiar layout, but it is not a requirement for barcolor() to reach the main chart. To draw a separate candle series, investigate plotcandle() rather than treating it as the same operation.
Change the Visual Rule Carefully
You can replace volume conditions with another calculation, such as price relative to an average. Define the calculation and missing-value behavior first, then map each state to a color. color.new() sets transparency from opaque at 0 to invisible at 100.
Pineify can help build custom visual rules, but generated source still needs compilation and output checks. A colored candle is a display aid, not a tested strategy or a guaranteed trade signal.
Does barcolor require overlay=true?
No. It colors the main chart's bars even when the script occupies another pane. Inspect visibility and competing scripts if the result is unclear.
Are these volume thresholds recommended settings?
No. They are adjustable teaching values. Check the actual feed, units, interval and session before choosing thresholds.
Why can the current candle change color?
The open bar's close and volume can change as data arrives. This example evaluates those current values.


