//+------------------------------------------------------------------+ 
//|                         _TRO_OPENS                               | 
//|                                                                  | 
//|                                                                  | 
//|   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 


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

extern bool show.M1  = false ;
extern bool show.M5  = false ;
extern bool show.M15 = false ;
extern bool show.H1  = true ;
extern bool show.H4  = false ;
extern bool show.D1  = true ;
extern bool show.W1  = true ;
extern bool show.MN1 = true ;





//---- buffers 
#property indicator_color1 Yellow
#property indicator_color2 Orange 
#property indicator_color3 Red
#property indicator_color4 Bisque 
#property indicator_color5 Pink
#property indicator_color6 White 
#property indicator_color7 PaleGreen 
#property indicator_color8 DodgerBlue 


double PlotM1[]; 
double PlotM5[]; 
double PlotM15[]; 
double PlotH1[]; 
double PlotH4[]; 
double PlotD1[]; 
double PlotW1[]; 
double PlotMN1[]; 


//+------------------------------------------------------------------+ 

double xOpen( int oPeriod, int oShift ) 
{
    int BarShift   = iBarShift(NULL,oPeriod,Time[oShift],true); 
    double oOpen   = iOpen(NULL,oPeriod,BarShift); 
    
return(oOpen) ;
}

//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
  { 
//---- indicators 
   SetIndexStyle(0,DRAW_ARROW); 
   SetIndexArrow(0,119); 
   SetIndexBuffer(0,PlotM5); 
   SetIndexEmptyValue(0,0.0); 
   SetIndexStyle(1,DRAW_ARROW); 
   SetIndexArrow(1,119); 
   SetIndexBuffer(1,PlotM5); 
   SetIndexEmptyValue(1,0.0); 
   SetIndexStyle(2,DRAW_ARROW); 
   SetIndexArrow(2,119); 
   SetIndexBuffer(2,PlotM15); 
   SetIndexEmptyValue(2,0.0); 
   SetIndexStyle(3,DRAW_ARROW); 
   SetIndexArrow(3,119); 
   SetIndexBuffer(3,PlotH1); 
   SetIndexEmptyValue(3,0.0); 
   SetIndexStyle(4,DRAW_ARROW); 
   SetIndexArrow(4,119); 
   SetIndexBuffer(4,PlotH4); 
   SetIndexEmptyValue(4,0.0); 
   
   SetIndexStyle(5,DRAW_LINE); 
   SetIndexArrow(5,119); 
   SetIndexBuffer(5,PlotD1); 
   SetIndexEmptyValue(5,0.0); 
   SetIndexStyle(6,DRAW_LINE); 
   SetIndexArrow(6,119); 
   SetIndexBuffer(6,PlotW1); 
   SetIndexEmptyValue(6,0.0); 
   SetIndexStyle(7,DRAW_LINE); 
   SetIndexArrow(7,119); 
   SetIndexBuffer(7,PlotMN1); 
   SetIndexEmptyValue(7,0.0); 
   
//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+ 
//| Custom indicator deinitialization function                       | 
//+------------------------------------------------------------------+ 
int deinit() 
  { 
//---- 
   ObjectDelete("Op1");    
   ObjectDelete("Op2");       
   ObjectDelete("Op3");    
   ObjectDelete("Op4");   
   ObjectDelete("Op5");    
   ObjectDelete("Op6");       
   ObjectDelete("Op7");    
   ObjectDelete("Op8");    
//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+ 
//| Custom indicator iteration function                              | 
//+------------------------------------------------------------------+ 
int start() 
  { 
   int    counted_bars=IndicatorCounted(); 
    if(counted_bars < 0) 
        return(-1); 
//---- 
   int limit=Bars-counted_bars; 
    

   int processBars=MathMin(limit, max_bars); 
   for(int i=0;i<=processBars;i++){ 
 
    int BarShift   = iBarShift(NULL,PERIOD_H1,Time[i],true); 
    double OpenH1  = iOpen(NULL,PERIOD_H1,BarShift); 
    
if( show.M1 )  PlotM1[i]  = xOpen(PERIOD_M1,i ) ;                       
if( show.M5 )  PlotM5[i]  = xOpen(PERIOD_M5,i ) ; 
if( show.M15 ) PlotM15[i] = xOpen(PERIOD_M15,i ) ; 
if( show.H1 )  PlotH1[i]  = xOpen(PERIOD_H1,i ) ; 
if( show.H4 )  PlotH4[i]  = xOpen(PERIOD_H4,i ) ; 
if( show.D1 )  PlotD1[i]  = xOpen(PERIOD_D1,i ) ; 
if( show.W1 )  PlotW1[i]  = xOpen(PERIOD_W1,i ) ; 
if( show.MN1 ) PlotMN1[i] = xOpen(PERIOD_MN1,i ) ; 
   
   } //end for 

 

if( show.M1 )  DoLabel( "Op1" , PlotM1[0]  , indicator_color1 ) ;
if( show.M5 )  DoLabel( "Op2" , PlotM5[0]  , indicator_color2 ) ;
if( show.M15 ) DoLabel( "Op3" , PlotM15[0] , indicator_color3 ) ;
if( show.H1 )  DoLabel( "Op4" , PlotH1[0]  , indicator_color4 ) ;
if( show.H4 )  DoLabel( "Op5" , PlotH4[0]  , indicator_color5 ) ;
if( show.D1 )  DoLabel( "Op6" , PlotD1[0]  , indicator_color6 ) ;
if( show.W1 )  DoLabel( "Op7" , PlotW1[0]  , indicator_color7 ) ;
if( show.MN1 ) DoLabel( "Op8" , PlotMN1[0] , indicator_color8 ) ;

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

void DoLabel( string dName, double dValue, color dColor )
{

     if (ObjectFind(dName) != 0)
      {
          ObjectCreate(dName,OBJ_ARROW,0,Time[0],dValue);
          ObjectSet(dName,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
          ObjectSet(dName,OBJPROP_COLOR,dColor);  
      } 
      else
      {
         ObjectMove(dName,0,Time[0],dValue);
      }
      
}
//+------------------------------------------------------------------+      
 

