ColorHSB
- specify color using Hue-Saturation-Brightness

Miscellaneous functions
(AmiBroker 4.80)


SYNTAX ColorHSB( hue, saturation, brightness )
RETURNS NUMBER
FUNCTION The function allows to specify color out of 16 million color (24 bit) palette using Hue, Saturation and Brightness parameters.

The return value is a number that can be used in Plot, PlotOHLC, PlotForeign, AddColumn, AddTextColumn functions to specify chart or column color.

Parameters:

  • hue - represents gradation of color within the optical spectrum (as in rainbow)
  • saturation represents "vibrancy" of the color
  • brightness represents brightness.

Each parameter ranges from 0 to 255, where 0 represents 0% saturation/brightness or 0 degree hue in HSV color wheel, and 255 represents 100% saturation/brightness or 360degrees hue in HSV color wheel.

When you modify hue from 0 to 255 you will see consecutive rainbow colors starting from red, through yellow and green to blue and violet.

For more information about HSB color space please read: http://en.wikipedia.org/wiki/HSB_color_space

EXAMPLE // Example 1:
// 3-d multicolor multiple moving average cloud chart
side =
1;
increment =
Param("Increment",2, 1, 10, 1 );
for( i = 10; i < 80; i = i + increment )
{
     up =
MA( C, i );
     down =
MA( C, i + increment );

  
if( ParamToggle("3D effect?", "No|Yes" ) )
     side =
IIf(up<=down AND Ref( up<=down, 1 ), 1, 0.6 );

  
PlotOHLC( up,up,down,down, "MA"+i, ColorHSB( 3*(i - 10),
  
Param("Saturation", 128, 0, 255 ),
     side *
Param("Brightness", 255, 0, 255 ) ), styleCloud | styleNoLabel );
}

// Example 2:
///////
//Color-parade exploration

Filter=1;
for( i = 0; i < 256; i = i + 16 )
  
AddColumn( C, "C", 1.2, colorDefault, ColorHSB( ( BarIndex() + i ) % 256, 255-i, 255 ) );
SEE ALSO ColorRGB() function , PLOT() function , AddColumn() function

References:

The ColorHSB function is used in the following formulas in AFL on-line library:

More information:

See updated/extended version on-line.