BACKGROUNDCOLOR

Category: Graphical

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.

Syntax:

BACKGROUNDCOLOR(R, G, B, a)
  • R: An integer representing the red component of the color (0-255).
  • G: An integer representing the green component of the color (0-255).
  • B: An integer representing the blue component of the color (0-255).
  • a: An integer representing the alpha (transparency) component of the color (0-255), where 0 is fully transparent and 255 is fully opaque.

Example:

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.

Additional Information:

  • The Stochastic indicator used in the example is a momentum indicator comparing a particular closing price of a security to a range of its prices over a certain period of time. The sensitivity of the oscillator to market movements is reducible by adjusting that time period or by taking a moving average of the result.
  • The Average True Range (ATR) is a technical analysis indicator that measures market volatility by decomposing the entire range of an asset price for that period.

Related Instructions:

  • ColorBetween instructions
  • COLOURED instructions
  • FILLCOLOR graphical
  • Logo Logo
    Loading...