The COLOURED function in ProBuilder language is used to apply color to a curve or line in a chart based on RGB values or predefined color names. This function enhances the visual representation of data by allowing users to differentiate between various data points or conditions with color.
The basic syntax for the COLOURED function is:
COLOURED(R, G, B)
COLOURED("colorname")
Where R, G, and B are integers representing the red, green, and blue components of the color, respectively. Alternatively, “colorname” can be used for common colors predefined in ProRealTime.
From version 10.3 onwards, an alpha parameter was introduced to control the transparency of the color:
COLOURED(R, G, B, alpha)
The alpha parameter ranges from 0 (completely transparent) to 255 (completely opaque).
To demonstrate the use of the COLOURED function, consider a scenario where you want to color a moving average line based on its relation to another moving average line:
i1 = average[10](close)
i2 = average[50](close)
if i1 > i2 then
a = 1
else
a = -1
endif
RETURN i2 COLOURED BY (a)
In this example, two moving averages are calculated: i1 with a period of 10 and i2 with a period of 50. The line representing i2 is colored based on the condition whether i1 is greater than i2. The color changes dynamically as the condition changes over time.
This function is particularly useful in financial charting where visual differentiation of data points or lines can provide quick insights into market conditions.