//+------------------------------------------------------------------+ 
//|   TRO_InsideBar                                                  | 
//|                                                                  | 
//|   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/" 

//---- indicator settings 
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_minimum 0
#property indicator_maximum 1



//---- indicator parameters  
 

extern int win = 0;
extern int price.x.offset= 0 ; 
extern int price.y.offset= 200 ; 


extern int   myFontSize       = 60;

extern int   myPeriod  = 0;

extern string IB_Message  = " InsideBar" ;
extern string NB_Message = "NB" ;
extern string OB_Message = " OutsideBar" ;


extern color IB_color = Turquoise;
extern color NB_color = DimGray;
extern color OB_color = Magenta;

 
string tMessage ;

//+--------- TRO MODIFICATION ---------------------------------------+ 
string symbol, tChartPeriod,  tShortName, oldmsg = "" ;  
int    digits, period  ; 

datetime Trigger ;

int OldBars = -1, TradeBars = 0 ;

color tColor = Yellow ;
color HighColor, LowColor, MidColor, Mid1Color, CloseColor, ClOpColor;
string sIB3531 ; 
 
//+------------------------------------------------------------------+ 
int init() 
  { 
   if(myPeriod == 0) { period = Period() ; } else { period = myPeriod ; }    
   tChartPeriod =  TimeFrameToString(period) ;
   symbol       =  Symbol() ;
   digits       =  Digits ;   

   tShortName = "IB3"+ symbol + tChartPeriod  ;

   tMessage  = NB_Message ;

   ClOpColor = NB_color ;

   sIB3531 = "SIB3531" ;

   return(0); 
  } 

//+------------------------------------------------------------------+
int deinit() 
{    

   ObjectDelete(sIB3531);

}  
 
//+------------------------------------------------------------------+ 
int start() 
  { 
double Open0, Open1, Open2, Close0, Close1, Close2, High0, High1, High2, Low0,  Low1, Low2, Range0, Range1, Range2, AvgRng3 ;
		
   Close0 = iClose(symbol,period,0) ; 
   Close1 = iClose(symbol,period,1) ;    
   Close2 = iClose(symbol,period,2) ;  
     
   Open0 = iOpen(symbol,period,0) ; 
   Open1 = iOpen(symbol,period,1) ;    
   Open2 = iOpen(symbol,period,2) ;  

   High0 = iHigh(symbol,period,0) ; 
   High1 = iHigh(symbol,period,1) ;    
   High2 = iHigh(symbol,period,2) ; 

   Low0 = iLow(symbol,period,0) ; 
   Low1 = iLow(symbol,period,1) ;    
   Low2 = iLow(symbol,period,2) ;    

   Range0 = High0 - Low0 ; 
   Range1 = High1 - Low1 ;    
   Range2 = High2 - Low2 ;





while(true)
{

if( High1 < High2 &&  Low1 > Low2 ) {tMessage =  tChartPeriod+ IB_Message ; ClOpColor = IB_color ; break ; }

if( High1 > High2 &&  Low1 < Low2 ) {tMessage =  tChartPeriod+ OB_Message ; ClOpColor = OB_color ; break ; }

tMessage = tChartPeriod+NB_Message ; ClOpColor = NB_color ;   
 
break;

} // while

oldmsg =  tMessage ;

//+------------------------------------------------------------------+  
                    
   ObjectCreate(sIB3531, OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText(sIB3531,tMessage, myFontSize , "Arial Bold", ClOpColor );
   ObjectSet(sIB3531, OBJPROP_CORNER, 0);
   ObjectSet(sIB3531, OBJPROP_XDISTANCE, price.x.offset); 
   ObjectSet(sIB3531, OBJPROP_YDISTANCE, price.y.offset); 


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


   WindowRedraw();    
 

   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);
}
//+------------------------------------------------------------------+