Download MetaTrader 5

OnChartEvent can't catch CHARTEVENT_OBJECT_CREATE

To add comments, please log in or register
Ming Luo
309
Ming Luo  

Hi all:

 

I write a simple code to catch the new created object on the chart.

 

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
   
   Print("id = ",id );
//--- the object has been deleted
   if(id==CHARTEVENT_OBJECT_DELETE)
     {
      Print("The object with name ",sparam," has been deleted");
     }
//--- the object has been created
   if(id==CHARTEVENT_OBJECT_CREATE )
     {
      Print("The object with name ",sparam," has been created");
     }
}

 

But whatever object I create on the chart, the function just can't catch it. Is this the bug of the new release of MT4? 

My MT4 version  is Build 840 (12 Jun 2015)

 Help please.

 

Thanks 

Keith Watford
Moderator
10611
Keith Watford  
   ChartSetInteger(0,CHART_EVENT_OBJECT_CREATE,true);
   ChartSetInteger(0,CHART_EVENT_OBJECT_DELETE,true);
Put these 2 lines in OnInit
To add comments, please log in or register