How to get chart position in X and Y ?

 

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

 
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
 
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.
 
You can't draw outside the chart.
 
#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).
Reason: