Chart Window Background Color

 

does anyone know how I can get the chart background color in mq4?

I want to able to automatically decide on the color to use for a symbol in an indicator.
e.g. If the chart is white, the use a black symbol, but if the chart is black, use a white symbol.

TIA

 

code from similar discussion 'Как определить цвет фона у терминала?'

#import "user32.dll"
   int GetDC(int hwnd);
   int ReleaseDC(int hwnd,int hdc);
#import "gdi32.dll"
   color GetPixel(int hdc,int x,int y);
#import
 
int start()
{   
   int hwnd=WindowHandle(Symbol(),Period());
   int hdc=GetDC(hwnd);
   color back_ground=GetPixel(hdc,1,2);
   ReleaseDC(hwnd,hdc);
   Print("Цвет фона "+back_ground);
   return(0);
}
 
Thanks, exactly what I needed!
 
Can I get to the chartzoom Level?
 

Hi stringo.


This is excellent, however I have to comment on some minor, though possible problems some may

encounter with using WindowHandle() for locating the chart's background color.


If the Symbol and TimeFrame (upper left hand corner) are not visible, the background color will return

a -1 value. If one were to reposition their chart just slightly to the left, where the Symbol and TimeFrame

display are hidden from view, you will see this take place. It makes me curious how exactly WindowHandle

works or renders, since the chart's symbol and timeframe must be 100% visible.


However, I don't think there is a better method available then what you have freely shared, so I am

not complaining and I do thank you.



 
MikeB:
I want to able to automatically decide on the color to use for a symbol in an indicator.
e.g. If the chart is white, the use a black symbol, but if the chart is black, use a white symbol.
Why not let the user decide what color to use via an extern parameter. Chart's don't need to be black or white.
 
MikeB: does anyone know how I can get the chart background color in mq4?
Build 600+ https://docs.mql4.com/en/constants/chartconstants/charts_samples#chart_color_background
Reason: