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


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

#property indicator_chart_window 

#property indicator_buffers 2

#property indicator_color1 Yellow 
#property indicator_color2 DodgerBlue
 

// indicators parameters
extern bool iPlotChart = true ;

extern int myPeriod=5; 
extern color myColor1 = Yellow ;
extern color myColor2 = DodgerBlue;

//---- buffers
double P1Buffer[];
double P2Buffer[];
 

int myStyle  = 2 ;

string tLHHL0 = "LHHL_0" ;
string tLHHL1 = "LHHL_1" ;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- name for indicator window

   string short_name=" ";
   IndicatorShortName(short_name);
   SetIndexBuffer(0, P1Buffer);
   SetIndexBuffer(1, P2Buffer);
 
//----

SetIndexArrow(0, 119); 
SetIndexArrow(1, 119); 


//   SetIndexStyle(0, DRAW_ARROW, myStyle, 1);
//   SetIndexStyle(1, DRAW_ARROW, myStyle, 1);   
   SetIndexStyle(0, DRAW_LINE, myStyle, 1);
   SetIndexStyle(1, DRAW_LINE, myStyle, 1);    
   
   // setting the indicator values, which will be invisible on the chart
   SetIndexEmptyValue(0,0); 
   SetIndexEmptyValue(1,0);


   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete(tLHHL0);
   ObjectDelete(tLHHL1);   
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

   int i, dayi, counted_bars = IndicatorCounted();
//---- check for possible errors
   if(counted_bars < 0) 
       return(-1);
//---- last counted bar will be recounted
   if(counted_bars > 0) 
       counted_bars--;  
   int limit = Bars - counted_bars;
//----   
   for(i = limit - 1; i >= 1; i--)
     {
        P1Buffer[i] = High[iLowest(NULL,0,MODE_HIGH,myPeriod,i)];
        P2Buffer[i] = Low[iHighest(NULL,0,MODE_LOW,myPeriod,i)];
     }    
 
 
if ( iPlotChart ) { 
  if (ObjectFind(tLHHL0) != 0)
      {
          ObjectCreate(tLHHL0,OBJ_ARROW,0,Time[0],P1Buffer[1]);
          ObjectSet(tLHHL0,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
          ObjectSet(tLHHL0,OBJPROP_COLOR,myColor1);  
      } 
      else
      {
         ObjectMove(tLHHL0,0,Time[0],P1Buffer[1]);
      }
 

    
    if (ObjectFind(tLHHL1) != 0)
      {
          ObjectCreate(tLHHL1,OBJ_ARROW,0,Time[0],P2Buffer[1]);
          ObjectSet(tLHHL1,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
          ObjectSet(tLHHL1,OBJPROP_COLOR,myColor2);  
      } 
      else
      {
         ObjectMove(tLHHL1,0,Time[0],P2Buffer[1]);
      }


} // iPlotChart 
 
 
 
   return(0);

  }