//+------------------------------------------------------------------+ 
//|  TRO_OneThird_OC                                                 | 
//|                                                                  | 
//|   Copyright © 2008, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFT AND DONATIONS ACCEPTED                                    | 
//|                                                                  |
//|   therumpldone@gmail.com                                         |  
//+------------------------------------------------------------------+ 
//|                                                                  |
//| go to www.kreslik.com for the latest indicator updates           |  
//+------------------------------------------------------------------+ 
//|                                                                  |
//| Use http://therumpledone.mbtrading.com/fx/ as your forex broker  |  
//| ...tell them therumpledone sent you!                             |  
//+------------------------------------------------------------------+  
//----
#define major   1
#define minor   0
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 OrangeRed
#property indicator_color2 DodgerBlue
#property indicator_color3 OrangeRed
#property indicator_color4 DodgerBlue
//----
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];

double Bias_Open, Bias_Close, Bias_High, Bias_Low, Bias_Diff, Bias_Mid, Bias_Pivot, Bias_Third, Bias_ThirdUp, Bias_ThirdDn ;
                                                   
//+------------------------------------------------------------------+
void init()
  {
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexBuffer(2, ExtMapBuffer3);
   SetIndexBuffer(3, ExtMapBuffer4);
//----        
   SetIndexStyle(0, DRAW_HISTOGRAM, 0, 1);
   SetIndexStyle(1, DRAW_HISTOGRAM, 0, 1);
   SetIndexStyle(2, DRAW_HISTOGRAM, 0, 3);
   SetIndexStyle(3, DRAW_HISTOGRAM, 0, 3);
  }
 
//+------------------------------------------------------------------+
void deinit()
  {
 
  }
 
//+------------------------------------------------------------------+
void start()
  {
   int counted = IndicatorCounted();
   if(counted < 0) 
     return (-1);
 
   if (counted > 0) 
     counted--;
   int limit = Bars-counted;
   
   for(int i = 0; i < limit; i++) 
     {
 
      Bias_Close   = iClose(NULL,0,i) ;   // close of the chart period
      Bias_Open    = iOpen(NULL,0,i) ;    // open of the Bias period  
      Bias_High    = iHigh(NULL,0,i) ;    // high of the Bias period 
      Bias_Low     = iLow(NULL,0,i) ;     // low of the Bias period 
      
      Bias_Third   = ( Bias_High - Bias_Low ) * 0.333333 ;
      
      Bias_ThirdUp = Bias_High - Bias_Third ;
      
      Bias_ThirdDn = Bias_Low + Bias_Third ;
       

       if(Bias_Close > Bias_ThirdUp && Bias_Open  < Bias_ThirdDn )
         {
           ExtMapBuffer1[i] = Low[i];
           ExtMapBuffer2[i] = High[i];
           ExtMapBuffer3[i] = MathMin(Open[i], Close[i]);
           ExtMapBuffer4[i] = MathMax(Open[i], Close[i]);
         } 

       if(Bias_Open  > Bias_ThirdUp && Bias_Close < Bias_ThirdDn)
         {
           ExtMapBuffer1[i] = High[i];
           ExtMapBuffer2[i] = Low[i];
           ExtMapBuffer3[i] = MathMax(Open[i], Close[i]);
           ExtMapBuffer4[i] = MathMin(Open[i], Close[i]);
         }
     }
     
  }  
//+------------------------------------------------------------------+

