The BACKGROUNDCOLOR function in ProBuilder language is used to change the background color of a chart based on specified RGB (Red, Green, Blue) values and an alpha value for transparency. This function can be particularly useful for visually highlighting certain conditions or thresholds directly on the chart’s background, enhancing the readability and analysis of trading indicators.
BACKGROUNDCOLOR(R, G, B, a)
sto = Stochastic[10,3](close)
signal = average[5](sto)
rge = averagetruerange[10](close)
if sto[1] > 80 and sto crosses under signal then
DRAWARROWDOWN(barindex[1], high[1] + rge/2) coloured(255, 10, 10)
direction = -1
elsif sto[1] < 20 and sto crosses over signal then
DRAWARROWUP(barindex[1], low[1] - rge/2) coloured(10, 255, 10)
direction = 1
endif
if direction > 0 then
BACKGROUNDCOLOR(10, 255, 10, 100)
else
BACKGROUNDCOLOR(255, 10, 10, 100)
endif
RETURN
In this example, the background color of the chart is set to a semi-transparent green (RGB: 10, 255, 10, Alpha: 100) when the stochastic indicator crosses over the signal line and is below 20, indicating a potential upward movement. Conversely, it sets the background to a semi-transparent red (RGB: 255, 10, 10, Alpha: 100) when the stochastic indicator crosses under the signal line and is above 80, indicating a potential downward movement.