I wouldn't advise using Labels and positions in pixels for your application . . . instead find the height of the window in pixels and convert your pixel offset into a price, then place your text based on time and price . . . it will then move correctly if the Y axis is resized.
To get the window dimensions in pixels use something like this . . .
#import "user32.dll" int GetWindowRect(int hWnd, int rect[4]); #import int WindowDims[4]; // used to store window coordinates from "user32.dll" int SizeX = 800; // x axis is width (pixels measured from left to right) int SizeY = 600; // y axis is height (pixels measured from top to bottom) if (IsDllsAllowed()) { GetWindowRect(WindowHandle(Symbol(), Period()), WindowDims); SizeX = WindowDims[2] - WindowDims[0]; SizeY = WindowDims[3] - WindowDims[1]; }
Well, this is exactly what I meant, only the most interesting part is missing ..:-) Of course it is easy to GetWindowsRect, but how to get the pixel offset of a price, that is where I am hoping to get soon ... :-)
Oh ...I think I am getting there ( at last ..:-D), so please bear with me for a couple of moments more. So it seems that what I have been missing is that the max-min price duo, these have nothing to do with the price displayed by the bars, but rather the 'price window' being shown by the 'y-axis' ..is this correct? And if that one is cleared, I still do not get it how I could pick an arbitrary price to put my text on ..? While having just the OHLC, how could I state 'put this text like 10 pixels above High[15]?
"max-min price duo, these have nothing to do with the price displayed by the bars, but rather the 'price window' being shown by the 'y-axis' ..is this correct?" - correct.
If there are 600 pixels from the top of the window to the bottom and the price max to min is 103.788 to 103.120 (EURJPY) then 10 pixels as a price will be ( (103.788 - 103.120) / 600 ) * 10 add this to your bar high.
So getting on with your calculation:
yCoordBuffer = ( (103.788 - 103.120) / 600 ) * 10, then into CreateObject goes
High[15] + yCoordBuffer?
So getting on with your calculation:
yCoordBuffer = ( (103.788 - 103.120) / 600 ) * 10, then into CreateObject goes
High[15] + yCoordBuffer?
Excellent! Now in closing - I would like to ask you about the reasons behind the very first line of yours here: "I wouldn't advise using ...". Why wouldn't you and why do you consider this method a better one for this achievement?
You should try both methods and see which is better for you.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi MQLers,
please advise: I am looking for a way to put a label (or even a text) above a specified bar so that it is positioned a specified number of pixel above the bar's high and moves along the window as new bars form. I guess the key to this funcionality is through being able to transform pixel coords to time/price coords and/or vice versa, and what I have been able to find throughout the web was fairly contradicting.. Could anybody help?
Mac