//+------------------------------------------------------------------+
//|             _TRO_LHHL_CHANNEL                                    |
//|                                                                  |
//|   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 4

#property indicator_color1 Yellow 
#property indicator_color2 DodgerBlue
#property indicator_color3 Yellow 
#property indicator_color4 DodgerBlue 

// indicators parameters
extern bool iPlotChart = true ;

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

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

int myStyle  = 2 ;

string tLHHL0 = "LHHL_0" ;
string tLHHL1 = "LHHL_1" ;
string tLHHL2 = "LHHL_2" ;
string tLHHL3 = "LHHL_3" ;

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

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

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

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

   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete(tLHHL0);
   ObjectDelete(tLHHL1);   
   ObjectDelete(tLHHL2);
   ObjectDelete(tLHHL3);   
   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)];
        P3Buffer[i] = High[iHighest(NULL,0,MODE_HIGH,myPeriod,i)];
        P4Buffer[i] = Low[iLowest(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]);
      }

  if (ObjectFind(tLHHL2) != 0)
      {
          ObjectCreate(tLHHL2,OBJ_ARROW,0,Time[0],P3Buffer[1]);
          ObjectSet(tLHHL2,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
          ObjectSet(tLHHL2,OBJPROP_COLOR,myColor1);  
      } 
      else
      {
         ObjectMove(tLHHL2,0,Time[0],P3Buffer[1]);
      }
 

    
    if (ObjectFind(tLHHL3) != 0)
      {
          ObjectCreate(tLHHL3,OBJ_ARROW,0,Time[0],P4Buffer[1]);
          ObjectSet(tLHHL3,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
          ObjectSet(tLHHL3,OBJPROP_COLOR,myColor2);  
      } 
      else
      {
         ObjectMove(tLHHL3,0,Time[0],P4Buffer[1]);
      }
} // iPlotChart 
 
 
 
   return(0);

  }