Download MetaTrader 5
To add comments, please log in or register
Write articles and earn money. We pay 200 USD for them!
John
79
John 2014.08.08 14:23 

Hi,

How can I detect a double click event on a Chart ?

I can do it for a single click using :

void OnChartEvent(const int id,

                  const long &lparam,

                  const double &dparam,

                  const string &sparam)

{


//new logic

   if(id==CHARTEVENT_CLICK)

   { ......

 

is there an CHARTEVENT_DOUBLECLICK  event ?

 

Thanks in advance. 

whroeder1
13644
whroeder1 2014.08.08 16:07  
jfortes: is there an CHARTEVENT_DOUBLECLICK  event ?
Do you see any in the documention? Types of Chart Events - MQL4 Documentation

Halley
198
Halley 2014.08.08 16:59  
jfortes:

Hi,

How can I detect a double click event on a Chart ?

I can do it for a single click using :

void OnChartEvent(const int id,

                  const long &lparam,

                  const double &dparam,

                  const string &sparam)

{


//new logic

   if(id==CHARTEVENT_CLICK)

   { ......

 

is there an CHARTEVENT_DOUBLECLICK  event ?

 

Thanks in advance. 


You cannot catch the system double-click event, but you may record the click time and coordinates and detect the double-click with your own metrics.
John
79
John 2014.08.08 20:35  

Thanks DeepThought, good suggestion.

I will try to implement the logic: if x,y coordinates are clicked twice then consider a double click event. Thanks. 

h3nrixd
4
h3nrixd 2016.06.09 02:21  
ulong click = 0;
ulong dclick = 200000;

int OnInit()
{
   return(INIT_SUCCEEDED);
}

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   return(rates_total);
}

void OnChartEvent(const int id,
                  const long& lparam,
                  const double& dparam,
                  const string& sparam)
{
   int x = (int)lparam;
   int y = (int)dparam;

   int window  = 0;
   datetime dt = 0;
   double   p  = 0;
   
   if (ChartXYToTimePrice(0, x, y, window, dt, p))
   {
      if (id == CHARTEVENT_CLICK)
      {
         if (GetMicrosecondCount() - click < dclick)
         {
            onDoubleClick(id, lparam, dparam, sparam);
            click = 0;
         } else {
            onClick(id, lparam, dparam, sparam);
            click = GetMicrosecondCount();
         }
      }
   }
}

void onDoubleClick(const int id,
                  const long& lparam,
                  const double& dparam,
                  const string& sparam)
{
   int x = (int)lparam;
   int y = (int)dparam;

   int window  = 0;
   datetime dt = 0;
   double   p  = 0;

   if (ChartXYToTimePrice(0, x, y, window, dt, p))
      onXYDoubleClick(window, x, y, dt, p);      
}

void onClick(const int id,
                  const long& lparam,
                  const double& dparam,
                  const string& sparam)
{
   int x = (int)lparam;
   int y = (int)dparam;

   int window  = 0;
   datetime dt = 0;
   double   p  = 0;

   if (ChartXYToTimePrice(0, x, y, window, dt, p))
      onXYClick(window, x, y, dt, p);      
}

void onXYDoubleClick(int window, int x, int y, datetime dt, double p)
{
}

void onXYClick(int window, int x, int y, datetime dt, double p)
{
}
/
To add comments, please log in or register