Download MetaTrader 5

Chart Event not working when the indicator using Chart Event is called from EA using iCustom function

To add comments, please log in or register
Write articles and earn money. We pay 200 USD for them!
Young Ho Seo
15875
Young Ho Seo 2014.09.11 21:58 

Hello People

In my recent project, I tried to call an indicator, which uses chart event and button objects, from EA using iCustom function.

After EA is loaded, the indicators are also loaded as the indicators are compiled as the part of resource of EA.  

However,  when I tried to click on the button from the indicator, nothing is happened.

I tried to print something to check if OnChartEvent function is working fine, but nothing is printed. I have no idea how to deal with this problem. Except OnChartEvent function problem, the other things are working fine from the indicators. Even buttons are correctly created.   

OnChartEvent function is the MQL5 built in function, and I have no idea how to go about this problem. Please share your idea if you have any.

Kind regards.

 

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

      if(id==CHARTEVENT_OBJECT_CLICK)
     {

         printf("button is clicked");     

     } 

} 
Biantoro Kunarto
14899
Biantoro Kunarto 2014.09.16 02:58  

Hi, maybe you have to add this :

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//--- Check the event by pressing a mouse button
   if(id==CHARTEVENT_OBJECT_CLICK)
     {
      string clickedChartObject=sparam;
      //--- If you click on the object with the name buttonID
      if(clickedChartObject==buttonID)
        {
          Print("button is clicked"); 
        }
      }
   }   

I already try it and its work. This example is taken from documentation.

Young Ho Seo
15875
Young Ho Seo 2014.09.16 09:24  
biantoro:

Hi, maybe you have to add this :

I already try it and its work. This example is taken from documentation.

Hi Thanks. Let me try and see it works.

The complication comes from the fact that I am calling the indicator using Object and Chart Event function with iCustom function after I embedded the indicator into resource in my EA.

Therefore, things would normally worked very well if the indicator is attached directly to charts. But when the indicator is called with iCustom, button object is drawn correctly but the button object with chart event is not function correctly.

Anyway, I will give a go with your idea.

Regards.

Young Ho Seo
15875
Young Ho Seo 2014.09.16 09:34  
biantoro:

Hi, maybe you have to add this :

I already try it and its work. This example is taken from documentation.

Just tried your ideas. However nothing is printed.

As I mentioned before, The complication comes from the fact that I am calling the indicator from iCustom function after I embedded the indicator into resource in my EA.  

Anyways, thanks for your idea.

Regards 

To add comments, please log in or register