//+------------------------------------------------------------------+
//|                                                   Close Line.mq4 |
//+------------------------------------------------------------------+

#property indicator_chart_window


input color  HilineLineColor    =  Aqua;
input int    HilineLineStyle    =  2;
input int    HilineLineWidth    =  0;
input bool   SetLineOnTop       = true;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
  //:::::::::::::::::::::::::::::::::::::::::::::
  double Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
  double Bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
  int Bars=Bars(Symbol(),PERIOD_CURRENT);
  double Point=Point();
  //Etc.
  //:::::::::::::::::::::::::::::::::::::::::::::::

//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+

void OnDeinit(const int reason)
  {
  
//----
   ObjectDelete(0,"closeline");
//----
   return;
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[])
  {
  

  Level("closeline",0,iClose(Symbol(),PERIOD_CURRENT,1), iTime(Symbol(),PERIOD_CURRENT,0),HilineLineWidth,HilineLineStyle,HilineLineColor,true);                      
                    
   return(rates_total);
  }
  
  
void Level(string Levels, int Window,double starts,double time,int w, int s,color clr, bool deletes)
  {
   if (deletes) ObjectDelete(0,Levels);
   if(ObjectFind(0,Levels)!=0)
     { 
         ObjectCreate(0,Levels, OBJ_HLINE, 0, iTime(Symbol(),PERIOD_CURRENT,0), starts,0);
         ObjectSetInteger(0,Levels, OBJPROP_COLOR, clr);
         ObjectSetInteger(0,Levels,OBJPROP_BACK,!SetLineOnTop);
         ObjectSetInteger(0,Levels,OBJPROP_WIDTH, w);
         ObjectSetInteger(0,Levels,OBJPROP_STYLE,s);
         
     }
   else
          ObjectMove(0,Levels, 0, 0, iTime(Symbol(),PERIOD_CURRENT,0));
  } 
  
