Hi RaptorUK,
thank's a lot for your answer!
But I don't understand very well how I can use that functions to calculate time and price from pixel coordinates?
I think to use that functions I need to know height and width of chart windows but I don't know. And if can calculate height and width (but I don't know how) for zoomed and traslated charts?
Try/Search on . . .
#import "user32.dll" int GetWindowRect(int hWnd, int rect[4]); #import . . . . if (IsDllsAllowed()) { GetWindowRect(WindowHandle(Symbol(), Period()), WindowDims); size_x = WindowDims[2] - WindowDims[0]; size_y = WindowDims[3] - WindowDims[1]; } else Print("DLLs not allowed ! !");
Thank's you si much RaptorUk,
That function return window chart dimension!
For price coordinate I use that formula:
pixelprice= (WindowPriceMax()-WindowPriceMin())/size_y;
selectedprice= WindowPriceMax() - (selected_y_pixel*pixelprice);
and with some little adjustement (remove from size_y the pixel height of board) it's precise enough.
But for time coordiante I can't understand how I can determine selected time using WindowBarsPerChart and size_x. There's the translation of chart and zoom to consider. I do some test but the result is not acceptable :-( Have you just resolv this problem??
Have you just resolv this problem??
...well, so I'll continue with my experiment.
If I'll find something good I'll post it here!
Thank's
I'm happy to report that I found the solution to my problem!! I use 2 line for calculate the pixel/time-price conversion
- 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,
I'm new to mql4 and I need some help: is possible convert pixel coordinates to time/price coordinates?
I'll do code for get mouse pointer coordinate at left mouse click, now, I'll want use that pixel coordinates to "select" a bar on my chart, but bars are only selected by time or index and I don't find a way to do this!
I've just test:
1) create a VLine to 0 time and 0 price, move to my pixel coodinates and read new time, but don't work the move by pixel coordinates
2) create a Label to my pixel coodinates and read Time1/ Price1, but time and price properties value on label aren't set.
2) generate a new drag and drop event on left mouse click to my coordinates and read TimeOnDropped() result, but don't work, because it save only pixel coordinates to script are initial dropped on chart
please help me!!!