//+------------------------------------------------------------------+ 
//|   TRO_BIAS_EZ                                                    | 
//|                                                                  | 
//|   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 corner = 1;
extern int price_x_offset= 0 ; 
extern int price_y_offset= 100 ; 


extern int   myFontSize = 100;
 

extern color UpS_color = Lime;
extern color UpW_color = Green;
extern color Eq_color  = Yellow;
extern color DnW_color = Maroon;
extern color DnS_color = Red;

//---- indicator buffers 


 

string Arrow12 = "ñ"; // 12 oclock
string Arrow2  = "ö";  // 2 oclock
string Arrow3  = "ð";  // 3 oclock
string Arrow5  = "ø";  // 5 oclock
string Arrow6  = "ò";  // 6 oclock
 

/*
string Arrow12 = "á";  // 12 oclock 225
string Arrow2  = "ã";  // 10 oclock 227
string Arrow3  = "ß";  //  9 oclock 223
string Arrow5  = "å";  //  7 oclock 229
string Arrow6  = "â";  //  6 oclock 226


string Arrow12 = "á";  // 12 oclock 225
string Arrow2  = "ä";  //  2 oclock 228
string Arrow3  = "à";  //  3 oclock 224
string Arrow5  = "æ";  //  5 oclock 230
string Arrow6  = "â";  //  6 oclock 226
*/

//+--------- TRO MODIFICATION ---------------------------------------+ 
string symbol, tChartPeriod,  tShortName ;  
int    digits, period, win = 0  ; 

datetime Trigger ;

int OldBars = -1 ;

color tColor = Yellow ;


color ClOpColor;

double H1Bias_Open, H1Bias_Close, H1Bias_High, H1Bias_Low, H1Bias_Diff, H1Bias_Mid, H1Bias_Pivot ;

string H1BiasMsg, tH1BiasPeroid ;
double D1Bias_Open, D1Bias_Close, D1Bias_High, D1Bias_Low, D1Bias_Diff, D1Bias_Mid, D1Bias_Pivot ;

string D1BiasMsg, tD1BiasPeroid ;

bool H1Bias_Long = false , H1Bias_Short = false ;
bool D1Bias_Long = false , D1Bias_Short = false ;
  
double Bias_Open, Bias_Close, Bias_High, Bias_Low, Bias_Diff, Bias_Mid, Bias_Pivot ;

string BiasMsg, tBiasPeroid, H1Arrow, D1Arrow, BiasArrow ;

bool Bias_Long = false , Bias_Short = false ;

color D1ColorBias = Yellow, H1ColorBias = Yellow, ColorBias = Yellow ;  

string Obj0001,Obj0002,Obj0003,Obj0004,Obj0005,Obj0006,Obj0007,Obj0008,Obj0009,Obj0010,Obj0011;  
 
//+------------------------------------------------------------------+ 
int init() 
  { 
   period       =  Period() ;     
   tChartPeriod =  TimeFrameToString(period) ;
   symbol       =  Symbol() ;
   digits       =  Digits ;   

   tShortName = "BEZ"+ symbol + tChartPeriod  ;

string tagname = "BEZ" ;

Obj0002 = tagname + "02" ; 
Obj0003 = tagname + "03" ; 
Obj0004 = tagname + "04" ; 
Obj0005 = tagname + "05" ; 

   return(0); 
  } 

//+------------------------------------------------------------------+ 

int deinit() 
{ 
   ObjectDelete(Obj0002); 
   ObjectDelete(Obj0003);
   ObjectDelete(Obj0004); 
   ObjectDelete(Obj0005); 

   return(0);     
}  
 
//+------------------------------------------------------------------+ 
int start() 
{ 
    
DoBias( 60 );
H1ColorBias = ColorBias  ; 
H1Arrow     = BiasArrow ;

DoBias(1440 );
D1ColorBias = ColorBias  ; 
D1Arrow     = BiasArrow ;
                    
   ObjectCreate(Obj0002, OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText(Obj0002,H1Arrow, myFontSize , "Wingdings", H1ColorBias );
   ObjectSet(Obj0002, OBJPROP_CORNER, corner);
   ObjectSet(Obj0002, OBJPROP_XDISTANCE, price_x_offset); 
   ObjectSet(Obj0002, OBJPROP_YDISTANCE, price_y_offset); 
   ObjectSet(Obj0002, OBJPROP_BACK, true );   

   ObjectCreate(Obj0004, OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText(Obj0004,"H1", myFontSize/4 , "Arial Bold", H1ColorBias );
   ObjectSet(Obj0004, OBJPROP_CORNER, corner);
   ObjectSet(Obj0004, OBJPROP_XDISTANCE, price_x_offset); 
   ObjectSet(Obj0004, OBJPROP_YDISTANCE, price_y_offset); 
   ObjectSet(Obj0004, OBJPROP_BACK, false );      
     
   ObjectCreate(Obj0003, OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText(Obj0003,D1Arrow, myFontSize , "Wingdings", D1ColorBias );
   ObjectSet(Obj0003, OBJPROP_CORNER, corner);
   ObjectSet(Obj0003, OBJPROP_XDISTANCE, price_x_offset+myFontSize); 
   ObjectSet(Obj0003, OBJPROP_YDISTANCE, price_y_offset); 
   ObjectSet(Obj0003, OBJPROP_BACK, true );     

   ObjectCreate(Obj0005, OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText(Obj0005,"D1", myFontSize/4 , "Arial Bold", D1ColorBias );
   ObjectSet(Obj0005, OBJPROP_CORNER, corner);
   ObjectSet(Obj0005, OBJPROP_XDISTANCE, price_x_offset+myFontSize); 
   ObjectSet(Obj0005, OBJPROP_YDISTANCE, price_y_offset); 
   ObjectSet(Obj0005, OBJPROP_BACK, false );   
       
   WindowRedraw();    

   return(0); 
} 

//+------------------------------------------------------------------+

void DoBias( int bPeriod ) 
{

Bias_Long  = false ; 
Bias_Short = false ;

 Bias_Close   = iClose(NULL,bPeriod,0) ; 
 Bias_Open    = iOpen(NULL,bPeriod,0) ;  
 Bias_High    = iHigh(NULL,bPeriod,1) ; 
 Bias_Low     = iLow(NULL,bPeriod,1) ;
 
  
 Bias_Diff    = Bias_Close - Bias_Open ;
 
 Bias_Mid     = ( Bias_High + Bias_Low ) * 0.50 ;
 Bias_Mid     = NormalizeDouble( Bias_Mid , digits ) ;
 
 Bias_Pivot   = ( Bias_High + Bias_Low + Bias_Close ) * 0.33333 ; 
 Bias_Pivot   = NormalizeDouble( Bias_Pivot , digits ) ; 
 
 
while( true )
{
   if (Bias_Diff > 0 && Bias_Close > Bias_Mid ) { BiasArrow = Arrow12; ColorBias = UpS_color ; break; } // strong up
   if (Bias_Diff > 0 && Bias_Close < Bias_Mid ) { BiasArrow = Arrow2 ; ColorBias = UpW_color ; break; } // weak up
   if (Bias_Diff < 0 && Bias_Close > Bias_Mid ) { BiasArrow = Arrow5 ; ColorBias = DnW_color ; break; } // weak down
   if (Bias_Diff < 0 && Bias_Close < Bias_Mid ) { BiasArrow = Arrow6 ; ColorBias = DnS_color ; break; } // strong down
                                                  BiasArrow = Arrow3 ; ColorBias = Eq_color  ; break;   // no bias
                                               
}                                                   

}

//+------------------------------------------------------------------+


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);
}

//+------------------------------------------------------------------+