ColorBetween

Category: Instructions

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.

Syntax:

ColorBetween(value1, value2, r, g, b, a)

or

ColorBetween(value1, value2, colorName, a)
  • value1 and value2: These parameters represent the two numerical values or data points between which the color will be applied.
  • r, g, b: These parameters are integers (ranging from 0 to 255) that define the red, green, and blue components of the color, respectively.
  • a (optional): This is an integer (ranging from 0 to 100) representing the alpha transparency level of the color, where 0 is fully transparent and 100 is fully opaque.
  • colorName: Instead of RGB values, a predefined color name (e.g., “red”, “blue”) can be used.

Example:

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.

Related Instructions:

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