OnChartEvent not properly working?

 

I would like to show and hide objects on a chart using the key "H". So I have added code to an indicator, but it is not working properly.


Code in OnInit

//---Allow Chart Events
   ChartSetInteger(0,CHART_EVENT_OBJECT_CREATE,true);
   ChartSetInteger(1,CHART_EVENT_OBJECT_CREATE,true);
   ChartSetInteger(0,CHART_EVENT_OBJECT_DELETE,true);
   ChartSetInteger(1,CHART_EVENT_OBJECT_DELETE,true);
   ChartSetInteger(1,CHART_EVENT_OBJECT_DELETE,true);
   ChartSetInteger(0,CHART_EVENT_MOUSE_MOVE,true);


Code OnChartEvent

void OnChartEvent(const int id,         // Event identifier  
                  const long& lparam,   // Event parameter of long type
                  const double& dparam, // Event parameter of double type
                  const string& sparam  // Event parameter of string type
                  )
{


   printf(IntegerToString(id));
   TotalNoOfObjects = ObjectsTotal(0,-1,-1); printf("OnChartEvent: TotalNoOfObjects = "+TotalNoOfObjects);

...

So each time a new object is added or deleted to/from the main chart window, TotalNoOfObjects should change, right? But nothing happens, not even a new print in the journal.

Any help appreciated.

 
Documentation on MQL5: Standard Constants, Enumerations and Structures / Chart Constants / Types of Chart Events
Documentation on MQL5: Standard Constants, Enumerations and Structures / Chart Constants / Types of Chart Events
  • www.mql5.com
Standard Constants, Enumerations and Structures / Chart Constants / Types of Chart Events - Reference on algorithmic/automated trading language for MetaTrader 5
 

Thank you Marco! I did know this... but in the end it helped me to find my stupid mistake. Problem solved!


Thanks for you help

 
blackfriday: my stupid mistake. Problem solved!
Always post something about the real problem and the solution in case someone searches, finds this thread, you wouldn't have wasted their time.
Reason: