Button Click like feature in MQL?

 

No wonder no one is responded to my question. Looks like cookie monster gobbled up my text. Now I have rethink my question.. here we go….

In one of videos I saw host playing with a text label (say CLOSEALL) on the chart. After the label was moved with cursor and arrival of fresh tick, the functionality attached to that label gets executed. In this case, it closes all the positions. And label moves back to the original position. This feature is quite close to button click like feature. Hence, this post.

How can we achieve that in MQL in MT4? Thanks

Pankaj

 
Keep track of the coordinates of an object using the ObjectGet() function ( OBJPROP_XDISTANCE and OBJPROPR_YDISTANCE ) when the coordinates change execute some code ...


int ObjectCoordinates = ObjectGet( "ObjectName", OBJPROP_XDISTANCE) * ObjectGet( "ObjectName", OBJPROP_YDISTANCE );

if( ObjectCoordinates != PrevObjectCoordinates )

{

PrevObjectCoordinates = ObjectCoordinates;


.... Do something like close all

}

 
you may follow https://forum.mql4.com/40727
Reason: