//+------------------------------------------------------------------+ 
//|   TRO_Break_Out                                                  | 
//|                                                                  | 
//|   Copyright © 2008, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFT AND DONATIONS ACCEPTED                                    | 
//|                                                                  |
//|   therumpledone@gmail.com                                        |  
//+------------------------------------------------------------------+ 
//|                                                                  |
//| go to www.kreslik.com for the latest indicator updates           |  
//+------------------------------------------------------------------+ 
//|                                                                  |
//| Use mbtrading as your forex broker...                            |  
//| http://therumpledone.mbtrading.com/fx/demo.asp                   |  
//+------------------------------------------------------------------+ 


#property indicator_chart_window

extern int       myPeriod = 60;
extern int       myBars   = 5;
extern int       myShift  = 1;



extern int Line_Style   = STYLE_DOT ;
extern int Line_Width   = 1 ;
extern color HighColor  = Red ;
extern color LowColor   = Blue ;


   double Period_high1[20];
   double Period_low1[20];

   double phigh,plow;
   
   
string Obj0001,Obj0002,Obj0003,Obj0004,Obj0005,Obj0006,Obj0007,Obj0008,Obj0009,Obj0010,Obj0011;  

string symbol, tChartPeriod,  tShortName, LabelTime, tMyPeriod ;  
int    digits, period, i  ; 

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

int init()
  { 

   period       = Period() ;   
   tChartPeriod = TimeFrameToString(period) ;
   symbol       = Symbol() ;
   LabelTime    = symbol + tChartPeriod + myBars + myPeriod + myShift ;  
   tMyPeriod    = TimeFrameToString(myPeriod) ;
   
   Obj0001 = "BKOUT_0001" + LabelTime ; 
   Obj0002 = "BKOUT_0002" + LabelTime ; 
   Obj0003 = "BKOUT_0003" + LabelTime ; 
   Obj0004 = "BKOUT_0004" + LabelTime ; 
     
ArrayResize(Period_high1,myBars+myShift+1);
ArrayResize(Period_low1,myBars+myShift+1);  
      
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
{
   ObjectDelete(Obj0001);  
   ObjectDelete(Obj0002); 
   ObjectDelete(Obj0003);
   ObjectDelete(Obj0004);
   
   return(0);
}
  
//+------------------------------------------------------------------+

int start()
{

ArrayInitialize(Period_high1,0);
ArrayInitialize(Period_low1,0);

ArrayCopySeries(Period_low1, MODE_LOW, Symbol(), myPeriod);
ArrayCopySeries(Period_high1, MODE_HIGH, Symbol(), myPeriod);


plow     =  Period_low1[1];
phigh    =  Period_high1[1];

for(i=myShift; i < myBars+myShift ;i++)
{
   if(plow  > Period_low1[i]) {plow  = Period_low1[i];}

   if(phigh < Period_high1[i]){phigh = Period_high1[i];}
}




deinit() ;

ObjectCreate(Obj0001, OBJ_HLINE,0, CurTime(),phigh);
ObjectSet(Obj0001,OBJPROP_COLOR,HighColor);
ObjectSet(Obj0001,OBJPROP_STYLE,Line_Style);
ObjectSet(Obj0001,OBJPROP_WIDTH,Line_Width);

ObjectCreate(Obj0002, OBJ_HLINE,0, CurTime(),plow);
ObjectSet(Obj0002,OBJPROP_COLOR,LowColor);
ObjectSet(Obj0002,OBJPROP_STYLE,Line_Style);
ObjectSet(Obj0002,OBJPROP_WIDTH,Line_Width);


ObjectDelete(Obj0003); 
ObjectCreate(Obj0003,OBJ_TEXT,0,Time[myBars],phigh) ;  
ObjectSetText(Obj0003,tMyPeriod+" HIGH("+myBars+")", 10, "Times New Roman", HighColor) ; 
     
ObjectDelete(Obj0004); 
ObjectCreate(Obj0004,OBJ_TEXT,0,Time[myBars],plow) ;  
ObjectSetText(Obj0004,tMyPeriod+" LOW("+myBars+")", 10, "Times New Roman", LowColor) ; 

ObjectsRedraw();

   return(0);
  }
  


//+------------------------------------------------------------------+
 
string TimeFrameToString(int tf)
{
   string tfs;
   switch(tf) {
      case PERIOD_M1:  tfs="M1"  ; break;
      case PERIOD_M5:  tfs="M5"  ; break;
      case PERIOD_M15: tfs="M15" ; break;
      case PERIOD_M30: tfs="M30" ; break;
      case PERIOD_H1:  tfs="H1"  ; break;
      case PERIOD_H4:  tfs="H4"  ; break;
      case PERIOD_D1:  tfs="D1"  ; break;
      case PERIOD_W1:  tfs="W1"  ; break;
      case PERIOD_MN1: tfs="MN";
   }
   return(tfs);
}

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