Download MetaTrader 5
To add comments, please log in or register
How to use MQL5.community messages editor? Find out in the article!
macpee
287
macpee 2016.10.06 01:46 

Hi comrades, I want to write a program to print "Printed Output" after the chat has been clicked. I have the following code which obviously did not work. Please how do I go about it? Thank you in advance.


 

void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
   {
   if (sparam == CHARTEVENT_CLICK)
       Print("Printed Output");
   }
Keith Watford
Moderator
7899
Keith Watford 2016.10.06 01:56  
if (sparam == CHARTEVENT_CLICK)

to

if (id == CHARTEVENT_CLICK)

.but you probably want to use CHARTEVENT_OBJECT_CLICK to only execute when a specific object has been clicked. Otherwise you will get repeated executuion everytime you click on the chart.

macpee
287
macpee 2016.10.06 02:03  
GumRai:

to

.but you probably want to use CHARTEVENT_OBJECT_CLICK to only execute when a specific object has been clicked. Otherwise you will get repeated executuion everytime you click on the chart.

Thank you so much. Actually I want to click on the chart and not on an object. I want any chat on top of the window to be the one to execute the event. But I have read the MQL4 help document and I can see X-cordinate, and Y-cordinate as the parameters to be passed through, including of course the CHARTEVENT_CLICK.

Also, the id alone does not seem to do anything after clicking on the chart. Do I have to add the coordinates, if yes how do I go about it?


Event of a mouse click on the chart

CHARTEVENT_CLICK

the X coordinate

the Y coordinate

macpee
287
macpee 2016.10.06 02:18  
Ok thanks, I think I got it.
/
To add comments, please log in or register