Download MetaTrader 5
To add comments, please log in or register
Have you just installed MetaTrader 5? Learn it in details!
MikeB
17
MikeB 2008.02.05 09:58 

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

Slawa
Moderator
6675
Slawa 2008.02.05 11:14  

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);
}
MikeB
17
MikeB 2008.02.05 13:58  
Thanks, exactly what I needed!
Heino
250
Heino 2008.02.06 00:27  
Can I get to the chartzoom Level?
JPS1
239
JPS1 2010.12.16 14:43  

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.



whroeder1
13590
whroeder1 2010.12.16 18:00  
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.
whroeder1
13590
whroeder1 2014.02.21 14:40  
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
/
To add comments, please log in or register