//+------------------------------------------------------------------+ 
//|                          _TRO_PRICE_LEVELS_TIME                  | 
//|                                                                  | 
//|   Copyright © 2008, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFTS AND DONATIONS ACCEPTED                                   | 
//|                                                                  |
//|   therumpledone@gmail.com                                        |  
//+------------------------------------------------------------------+ 

#property  copyright "Copyright © 2008, Avery T. Horton, Jr. aka TRO" 
#property  link      "http://www.therumpledone.com/" 

#property indicator_chart_window 
#property indicator_buffers 8 
#property indicator_color1 Blue
#property indicator_color2 Blue 
#property indicator_color3 Blue
#property indicator_color4 Blue 
#property indicator_color5 Orange
#property indicator_color6 Orange 
#property indicator_color7 Orange 
#property indicator_color8 Orange 

//---- input parameters 
extern  int      max_bars  = 1440; 

extern  int      myHour    = 00 ;
extern  int      myMinute  = 00 ;

extern  bool use.midpoint  = true;

extern double    iLevel1=10; 
extern double    iLevel2=20; 
extern double    iLevel3=40; 
extern double    iLevel4=80; 


//---- buffers 

double fb1[]; 
double fb2[]; 
double fb3[]; 
double fb4[]; 
double fb5[]; 
double fb6[]; 
double fb7[]; 
double fb8[]; 


//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
  { 
//---- indicators 
   SetIndexStyle(0,DRAW_ARROW); 
   SetIndexArrow(0,119); 
   SetIndexBuffer(0,fb1); 
   SetIndexEmptyValue(0,0.0); 
   SetIndexStyle(1,DRAW_ARROW); 
   SetIndexArrow(1,119); 
   SetIndexBuffer(1,fb2); 
   SetIndexEmptyValue(1,0.0); 
   SetIndexStyle(2,DRAW_ARROW); 
   SetIndexArrow(2,119); 
   SetIndexBuffer(2,fb3); 
   SetIndexEmptyValue(2,0.0); 
   SetIndexStyle(3,DRAW_ARROW); 
   SetIndexArrow(3,119); 
   SetIndexBuffer(3,fb4); 
   SetIndexEmptyValue(3,0.0); 
   SetIndexStyle(4,DRAW_ARROW); 
   SetIndexArrow(4,119); 
   SetIndexBuffer(4,fb5); 
   SetIndexEmptyValue(4,0.0); 
   SetIndexStyle(5,DRAW_ARROW); 
   SetIndexArrow(5,119); 
   SetIndexBuffer(5,fb6); 
   SetIndexEmptyValue(5,0.0); 
   SetIndexStyle(6,DRAW_ARROW); 
   SetIndexArrow(6,119); 
   SetIndexBuffer(6,fb7); 
   SetIndexEmptyValue(6,0.0); 
   SetIndexStyle(7,DRAW_ARROW); 
   SetIndexArrow(7,119); 
   SetIndexBuffer(7,fb8); 
   SetIndexEmptyValue(7,0.0); 
   
//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+ 
//| Custom indicator deinitialization function                       | 
//+------------------------------------------------------------------+ 
int deinit() 
  { 

   return(0); 
  } 
//+------------------------------------------------------------------+ 
//| Custom indicator iteration function                              | 
//+------------------------------------------------------------------+ 
int start() 
  { 
   int    counted_bars=IndicatorCounted(),h,m;
    
    if(counted_bars < 0) 
        return(-1); 
//---- 
   int limit=Bars-counted_bars; 
    
   double range, xLevel; 


int processBars=MathMin(limit, max_bars); 

for(int i=processBars;i>=0;i--){ 
  
h=TimeHour(Time[i]);
m=TimeMinute(Time[i]);
  
if( h == myHour && m == myMinute )
{ 

    int BarShift   = iBarShift(NULL,PERIOD_H1,Time[i],true); 
    double OpenH1  = iOpen(NULL,PERIOD_H1,BarShift); 
    double HighH1  = iHigh(NULL,PERIOD_H1,BarShift); 
    double LowH1   = iLow(NULL,PERIOD_H1,BarShift);  
        
if ( use.midpoint ) { xLevel = (HighH1 + LowH1) * 0.5  ; }
else                { xLevel = OpenH1 ; }

} // if 
            fb1[i] = xLevel + iLevel1*Point; 
            fb2[i] = xLevel + iLevel2*Point;  
            fb3[i] = xLevel + iLevel3*Point;  
            fb4[i] = xLevel + iLevel4*Point;  
            fb5[i] = xLevel - iLevel4*Point;  
            fb6[i] = xLevel - iLevel3*Point;  
            fb7[i] = xLevel - iLevel2*Point;  
            fb8[i] = xLevel - iLevel1*Point;           

} //end for 

/*
Comment( "xLevel=", DoubleToStr(xLevel,Digits), "\n",
         "fb1[0]=", DoubleToStr(fb1[0],Digits), "\n",
         "Point=", Point, "\n",                  
         " ") ;
*/

return(0); 
} 
//+------------------------------------------------------------------+ 

