//+------------------------------------------------------------------+
//|                                           Time_Vertical_Line.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property show_inputs
extern bool PlotEveryMonth=TRUE;
extern int Mon=3;
extern int Day=24;


// extern int MaxBars=5000;
extern bool DeleteLines=TRUE;

extern int LineWdth = 2;
extern color LineColor = FireBrick;
string ID="TVL_";
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start(){
  
//----
if(DeleteLines){
DeleteObjects(ID);
}

for (int i = 1; i < Bars-1; i++) {

if(PlotEveryMonth){
if(TimeDay(Time[i]) == Day && TimeHour(Time[i])<1){
DrawVLine(i);
}
}
else{
if(TimeDay(Time[i]) == Day && TimeMonth(Time[i]) == Mon && TimeHour(Time[i])<1){
DrawVLine(i);
}
}

}//for


   return(0);
}
 //+------------------------------------------------------------------+
//                                                                   +
//+------------------------------------------------------------------+
void DrawVLine(int thisi){

string TimeNow=TimeToStr(Time[thisi],TIME_DATE);

string sObjName=ID+"vline"+TimeNow;
  ObjectCreate(sObjName, OBJ_VLINE, 0,Time[thisi],0);
  ObjectSet(sObjName, OBJPROP_COLOR, LineColor);
  ObjectSet(sObjName, OBJPROP_STYLE, STYLE_SOLID);
  ObjectSet(sObjName, OBJPROP_WIDTH, LineWdth);
  
 return;
}
//+------------------------------------------------------------------+
//                                                                   +
//+------------------------------------------------------------------+
void DeleteObjects(string label){
   int objs = ObjectsTotal();
   string name;
   for(int cnt=ObjectsTotal()-1;cnt>=0;cnt--)
   {
      name=ObjectName(cnt);
      if (StringFind(name,label,0)>-1) ObjectDelete(name);
      WindowRedraw();
   }
   
 return;
}
