//+------------------------------------------------------------------+
//|                                                            L.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
#property version   "1.00"
#property strict
#property indicator_chart_window
extern int N = 1000;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
  
//+------------------------------------------------------------------+
//| 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[])
  {
//---
   LN("R",  Close[0],White);
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

void LN ( string nm , double val , color cl )
{
   ObjectDelete(nm);
   ObjectCreate ( 0 , nm , OBJ_HLINE , 0 , Time[0] , val ) ;
   ObjectSetInteger(0, nm, OBJPROP_COLOR, DimGray);

   string nmL = nm + "_Label";
   double ar = iRSI(Symbol(),0,14,PRICE_CLOSE,0);
   string s = "rsi: "+DoubleToStr(ar,2);
   

   string nmT = s;
   
   ObjectDelete(nmL);
   ObjectCreate ( 0 , nmL , OBJ_TEXT , 0 , Time[0]+(Period()*N) , val );
   ObjectSetText ( nmL , nmT , 12 , "Tahoma", cl);
      
}

