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); }
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.
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.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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