GetChartBkColor returns correct value, was: wrong value

SetChartBkColor(colorWhite) -> GetChartBkColor() -> returns ColorRGB(0,0,255)

sb ColorRGB(0,0,0)? 16777215? This looks like the RGB value for colorSkyblue. What's up with that?

Is there a better way than this to get RGB values for color constants?

Not true.
I am getting color white (see price candles and color picker result on the top left).

SetChartBkColor( colorWhite );

get = GetChartBkColor();
SetBarFillColor( get );
Plot( C, "Price", colorDefault, styleCandle );


Please don't use SMS style. It is not "Mickey Mouse Club" with "Britney loves Justin" show here.
If you mean "It should be" then do write "It should be".

And white would be colorRGB(255,255,255). Three times zero is color black.


As for DEC value of white... it is 16777215 which is 8 digits.
Read here

rgb = GetChartBkColor() -56;

returns 16777216.
that's why you get 0, 0, 256 if doing

red = ( rgb & 255 ); 
green = floor( (rgb/256) & 255 ); 
blue = floor( rgb/(256*256) ); 

@yellowslug did you look at the code example of the GetChartBkColor() function?

Returns color value of chart background. Color value in AmiBroker is either one of predefined color constants (colorWhite, colorBlack), or RGB value with offset of 56 (number of predefined colors). So to get actual RGB value you need to subtract 56 from the result of that function.

Did you take into account the "offset"?

As other mentioned, you GetChartBKColor returns CORRECT value. But you did not read the manual:
https://www.amibroker.com/guide/afl/getchartbkcolor.html

If you did you will notice the sentence from the manual:

Color value in AmiBroker is either one of predefined color constants (colorWhite, colorBlack), or RGB value with offset of 56 (number of predefined colors).

the sample code that shows how to get correct RGB values and that there is a 56 offset in returned value because first 56 colors refer to palettized color entries.

So once again, ReadThisFineManual.

thanks for the pointer to AB precision... i looked but did not find it.

Yes, u r correct, white is RGB(255,255,255). i got it backwards.

Yes, i adjusted the offset by 56.

so the answer is that there r not enough significant digits 4 GetChartBkColor to differentiate all color constants... minimmaly colorBlue and colorWhite return the same values

No, you are mistaken.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.