ColorBetween
ColorBetween fills the area between two curves or values with a color in ProBuilder charts. Define the fill with RGB components or a named color and alpha.
Syntax
ColorBetween(value1, value2, r, g, b, a)With a named color:
ColorBetween(value1, value2, colorName, a)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
value1 | numeric | required | First boundary of the filled zone. |
value2 | numeric | required | Second boundary of the filled zone. |
r, g, b | integer 0 to 255 | required in RGB form | Red, green, and blue components of the fill color. |
colorName | string | required in named form | Predefined color name such as "red" or "blue", used instead of RGB. |
a | integer 0 to 100 | opaque | Transparency, 0 fully transparent to 100 fully opaque. |
How it works
ColorBetween shades the vertical band between two values on each bar. When the two values are indicator curves, the shaded bands join up across bars into a continuous filled region, which is the usual way to visualize the spread between two moving averages, the interior of a channel, or the distance between price and a reference line.
The order of the two boundary values does not carry meaning; the zone between them is filled either way. What often does matter is calling the function conditionally: wrapping ColorBetween calls in IF blocks allows the fill color to encode state, for example green when the fast average is above the slow one and red otherwise.
The fill is layered above the default chart background, but color instructions that execute later in the script can override it in the same region. Transparency is specified on a 0 to 100 scale, and moderate values around 50 keep candles readable through the fill.
ColorBetween belongs to the indicator drawing toolset. It has no effect in ProScreener, and strategy code in ProBacktest and ProOrder does not render chart fills; visual context for a strategy is normally added by attaching an indicator carrying the ColorBetween calls to the chart.
Examples
Example 1, Shading the gap between two moving averages (Indicator)
ma1 = average[7]
ma2 = average[20]
IF ma1 > ma2 THEN
ColorBetween(ma1, ma2, 0, 255, 0, 50) // green fill at 50 percent opacity
ELSE
ColorBetween(ma1, ma2, "red", 50) // red fill at 50 percent opacity
ENDIF
RETURNThe area between a 7-period and a 20-period average is shaded green while the fast average leads and red while it lags, making the current regime readable at a glance.
Example 2, Filling a Bollinger channel (Indicator)
upper = BollingerUp[20](close)
lower = BollingerDown[20](close)
// Light blue fill across the whole band
ColorBetween(upper, lower, 100, 149, 237, 25)
RETURN upper AS "Upper band", lower AS "Lower band"A single ColorBetween call shades the full Bollinger channel with a faint fill, while the RETURN statement still plots the band boundaries as lines.
Example 3, Highlighting price extension from its average (Indicator)
baseline = ExponentialAverage[50](close)
gap = ABS(close - baseline)
threshold = AverageTrueRange[14](close) * 2
// Shade only when price is stretched more than two ATRs from the baseline
IF gap > threshold THEN
ColorBetween(close, baseline, 255, 165, 0, 60) // orange warning fill
ENDIF
RETURN baseline AS "EMA 50"The fill appears only on bars where price is extended more than two ATRs from its exponential average, so the shading itself acts as an overextension signal.
Common errors and gotchas
- Alpha runs 0 to 100. ColorBetween transparency uses a 0 to 100 scale, unlike the COLOURED alpha which runs 0 to 255. Copying a 255 opacity value across produces an out-of-range argument.
- Indicator-only rendering. The function draws nothing in ProScreener, ProBacktest, or ProOrder code. Attach an indicator with the ColorBetween logic to the chart instead.
- Later colors win. Subsequent color instructions in the same script can paint over the filled zone. Order the drawing calls deliberately when combining fills, backgrounds, and colored curves.
- Fills without visible curves. ColorBetween shades between values whether or not they are returned. Unless the boundary series are also plotted via RETURN, the fill appears to float, which is sometimes intended and sometimes a forgotten RETURN.
Related instructions
COLOURED, colors a returned curve, statically or by condition.BACKGROUNDCOLOR, colors the entire chart background per bar.FILLCOLOR, fill color control for drawn shapes.DRAWRECTANGLE, draws a rectangle between explicit coordinates.Average, moving average, a typical fill boundary.BollingerUp, upper Bollinger band, usable as a zone boundary.BollingerDown, lower Bollinger band, usable as a zone boundary.RETURN, plots the curves that a fill usually accompanies.
