//+------------------------------------------------------------------+
//|                                                    Example 3.mq5 |
//|                              Copyright 2011, Alexander Piechotta |
//|                                        http://www.metatraders.de |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011, Alexander Piechotta"
#property link      "http://www.metatraders.de"
#property version   "1.00"
#include <MyComment.mqh>
MyComment AddComment;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   long p_handle=0;
   long handle=ChartNext(p_handle);
   while(handle!=-1)
     {
      p_handle=handle;
      AddComment.chartID=handle;
      AddComment.Add_MyComment("This comment will be deleted in 10 Sektunden on the GBPUSD.");
      handle=ChartNext(p_handle);
     }
//--- create timer
   EventSetTimer(10);
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   long p_handle=0;
   long handle=ChartNext(p_handle);
   while(handle!=-1)
     {
      p_handle=handle;
      // delete all my Comments from Symbol GBPUSD
      if(ChartSymbol(handle)=="GBPUSD")
        {
         AddComment.chartID=handle;
         AddComment.Del_MyComments();
        }
      handle=ChartNext(p_handle);
     }
  }
//+------------------------------------------------------------------+
Comments