//+------------------------------------------------------------------+
//|                                                close-sup-res.mq4 |
//|                Copyright © 2006, Nick Bilak, beluck[AT]gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Nick Bilak"
#property link      "http://www.mql4.info/"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Aqua



extern string CloseTime="22:59";




/*
STYLE_SOLID 0 The pen is solid. 
STYLE_DASH 1 The pen is dashed. 
STYLE_DOT 2 The pen is dotted. 
STYLE_DASHDOT 3 The pen has alternating dashes and dots. 
STYLE_DASHDOTDOT 4 The pen has alternating dashes and double dots. 
*/
extern int R3style=0;
extern int R3width=0;
int R3lev=0;
int DrawBars=0;
double R3Buffer[];
double C,R3;


int init()  {
   string short_name;
   SetIndexStyle(0,DRAW_LINE,R3style,R3width);

   SetIndexBuffer(0,R3Buffer);


   short_name="open_USD";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"R3");


   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {

   int    x,counted_bars=IndicatorCounted();
   
   
   int limit, i, dbars;
   //---- indicator calculation
   if (counted_bars==0) {
      x=Period();
      if (x>240) return(-1);
   }
   if(counted_bars<0) return(-1);
   if (DrawBars>0) limit=DrawBars;
   else limit=(Bars-counted_bars)+1;
   
   string prevd;
   for (i=limit; i>=0;i--) { 
      prevd=TimeToStr(Time[i+1],TIME_DATE);
      if (Time[i]>StrToTime(prevd+" "+CloseTime) && Time[i+1]<=StrToTime(prevd+" "+CloseTime)) {
         C = Close[i+1];
         R3 = C+R3lev*Point;

      }

      R3Buffer[i]=R3;
   }
   return(0);
}

