The ColorBetween function in ProBuilder language is designed to visually highlight the area between two specified values on a chart by filling it with a specified color. This function is particularly useful for emphasizing the range between two data points or indicators, making it easier to visualize relationships or differences between them. The color applied by this function takes precedence over the default background but can be overridden by subsequent color settings defined later in the code.
ColorBetween(value1, value2, r, g, b, a)
or
ColorBetween(value1, value2, colorName, a)
This example demonstrates how to use ColorBetween to color the area between two moving averages on a chart. The color green is used when the first moving average is above the second, and red when it is below.
ma1 = average[7]
ma2 = average[20]
if ma1 > ma2 then
ColorBetween(ma1, ma2, 0, 255, 0, 50) // Green with 50% transparency
else
ColorBetween(ma1, ma2, "red", 50) // Red with 50% transparency
endif
return
This function can be particularly useful for traders and analysts to quickly identify and assess the relationship between indicators or data points, enhancing visual analysis and decision-making processes on trading platforms that support ProBuilder language.