Download MetaTrader 5

How to get chart position in X and Y ?

To add comments, please log in or register
Pumin Wuvanich
24
Pumin Wuvanich  

Hi,

H‌ow do I get get X and Y value to determine chart position?  Is there a function or any work around to get values?  I try to look but couldn't find it.

Please see screenshot.  

‌Thanks in advance!

‌‌Regards,
Pumin

Roberto Jacobs
48489
Roberto Jacobs  
Pumin Wuvanich:

Hi,

H‌ow do I get get X and Y value to determine chart position?  Is there a function or any work around to get values?  I try to look but couldn't find it.

Please see screenshot.  

‌Thanks in advance!

‌‌Regards,
Pumin

you can see in the document

‌https://www.mql5.com/en/docs/chart_operations/charttimepricetoxy

or

‌https://www.mql5.com/en/docs/chart_operations/chartxytotimeprice

Documentation on MQL5: Chart Operations / ChartTimePriceToXY
Documentation on MQL5: Chart Operations / ChartTimePriceToXY
  • www.mql5.com
Chart Operations / ChartTimePriceToXY - Reference on algorithmic/automated trading language for MetaTrader 5
Pumin Wuvanich
24
Pumin Wuvanich  
Roberto Jacobs:

you can see in the document

‌https://www.mql5.com/en/docs/chart_operations/charttimepricetoxy

or

‌https://www.mql5.com/en/docs/chart_operations/chartxytotimeprice


Thanks for your suggestion Roberto.  However,   X and Y is outside chart so it's not related any time or price.  Please see the red arrow that I draw on screenshot.
whroeder1
15917
whroeder1  
You can't draw outside the chart.
honest_knave
Moderator
2326
honest_knave  
#property strict

#import "user32.dll"
   int  GetParent(int hWnd);
   int  GetWindowRect(int hWnd, int &rect[4]); 
#import

void OnStart()
  {
   int r[4];
   int handle=(int)ChartGetInteger(0,CHART_WINDOW_HANDLE);
   GetWindowRect(GetParent(GetParent(handle)),r);
   printf("X: %i Y: %i",r[0],r[1]);
  }
That should give you something to start with. It will give you the x/y coordinates of the chart relative to the screen (not relative to the terminal window).
To add comments, please log in or register