//+------------------------------------------------------------------+ 
//|   TRO_PRICE_EZ2                                                  | 
//|                                                                  | 
//|   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= -750 ;//250
extern int price.y.offset= -160 ;//-160

extern int   Chart_Period    = PERIOD_D1;

extern color Up_color = Lime;
extern color Eq_color = Yellow;
extern color Dn_color = Red;




//---- indicator buffers 


double     MaxRange = 0 ; 
double     MinRange = 0 ; 
double     AvgRange = 0 ; 
double     xRange   = 0 ; 
double     tRange   = 0 ; 
 


//---- buffers


double zRANGE = 0;

bool  show.info       = true;
bool  ShowChart       = true; 



string Arrow12 = "ñ"; // 12 oclock
string Arrow2  = "ö";  // 2 oclock
string Arrow3  = "ð";  // 3 oclock
string Arrow5  = "ø";  // 5 oclock
string Arrow6  = "ò";  // 6 oclock

//+------------------------------------------------------------------+
color fColor( double i, double j)
{
color rColor ;

    if ( i > j ) rColor = Up_color; 
    else {
    if ( i < j )  rColor = Dn_color; 
    else rColor = Eq_color; }
return ( rColor );
}


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


string fCompass( double i, double j)
{
string rCompass ;

    if ( i > j ) rCompass = Arrow12 ; 
    else {
    if ( i < j )  rCompass = Arrow6  ; 
    else rCompass = Arrow3 ; }
return ( rCompass );
}


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


int init() 
  { 

  if(Chart_Period == 0) { Chart_Period = Period() ; }

   return(0); 
  } 

int deinit() 
{ 

   
   ObjectDelete("PRC030");
   ObjectDelete("PRC029");
   ObjectDelete("PRC029B");
   ObjectDelete("PRC031");
   ObjectDelete("PRC032");
   ObjectDelete("PRC034");   
   
   ObjectDelete("PRC130");
   ObjectDelete("PRC129");
   ObjectDelete("PRC129B");
   ObjectDelete("PRC131");
   ObjectDelete("PRC132");
   ObjectDelete("PRC134");   
}  
 
//+------------------------------------------------------------------+ 
int start() 
  { 
  
double open   = iOpen(NULL,Chart_Period,0) ; 
double close  = iClose(NULL,Chart_Period,0) ; 
double close1 = iClose(NULL,Chart_Period,1) ; 
double high   = iHigh(NULL,Chart_Period,0) ; 
double high1  = iHigh(NULL,Chart_Period,1) ;
double low    = iLow(NULL,Chart_Period,0) ; 
double low1   = iLow(NULL,Chart_Period,1) ;

double mid    = ( high + low )   * 0.50 ; 
double mid1   = ( high1 + low1 ) * 0.50 ; 


color HighColor, LowColor, MidColor, Mid1Color, CloseColor, ClOpColor;

HighColor  = fColor( high, high1 ) ;
LowColor   = fColor( low, low1 ) ;
MidColor   = fColor( close, mid ) ;
Mid1Color  = fColor( close, mid1 ) ;
CloseColor = fColor( close, close1 ) ;
ClOpColor  = fColor( close, open ) ;


string CloseDir = fCompass( close, close1 ) ;
string HighDir  = fCompass( high, high1 ) ;
string LowDir   = fCompass( low, low1 ) ;
string MidDir   = fCompass( close, mid ) ;
string Mid1Dir  = fCompass( close, mid1 ) ;
string ClOpDir  = fCompass( close, open ) ;

string tPeriod = " "+TimeFrameToString( Chart_Period ) ;


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

   ObjectCreate("PRC030", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("PRC030",tPeriod + " PRICE", 30, "Arial Bold", CloseColor );
   ObjectSet("PRC030", OBJPROP_CORNER, 0);
   ObjectSet("PRC030", OBJPROP_XDISTANCE, 780+price.x.offset); // 760
   ObjectSet("PRC030", OBJPROP_YDISTANCE, 160+price.y.offset); // 160
   

//+------------------------------------------------------------------+ 
                     
   ObjectCreate("PRC029", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("PRC029",DoubleToStr(high, Digits ), 15, "Arial Bold", HighColor );
   ObjectSet("PRC029", OBJPROP_CORNER, 0);
   ObjectSet("PRC029", OBJPROP_XDISTANCE, 770+price.x.offset);
   ObjectSet("PRC029", OBJPROP_YDISTANCE, 197+price.y.offset);
   
   ObjectCreate("PRC129", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("PRC129",HighDir, 15, "Wingdings" , HighColor );
   ObjectSet("PRC129", OBJPROP_CORNER, 0);
   ObjectSet("PRC129", OBJPROP_XDISTANCE, 835+price.x.offset);
   ObjectSet("PRC129", OBJPROP_YDISTANCE, 197+price.y.offset);   

//+------------------------------------------------------------------+ 
 
   
   ObjectCreate("PRC029b", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("PRC029b",DoubleToStr( low ,  Digits ), 15, "Arial Bold", LowColor );
   ObjectSet("PRC029b", OBJPROP_CORNER, 0);
   ObjectSet("PRC029b", OBJPROP_XDISTANCE, 770+price.x.offset);
   ObjectSet("PRC029b", OBJPROP_YDISTANCE, 260+price.y.offset);                                      
   
   ObjectCreate("PRC129b", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("PRC129b",LowDir , 15, "Wingdings" , LowColor );
   ObjectSet("PRC129b", OBJPROP_CORNER, 0);
   ObjectSet("PRC129b", OBJPROP_XDISTANCE, 835+price.x.offset);
   ObjectSet("PRC129b", OBJPROP_YDISTANCE, 260+price.y.offset);                 

//+------------------------------------------------------------------+ 
                     
   ObjectCreate("PRC031", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("PRC031",DoubleToStr(close, Digits ), 40, "Arial Bold", ClOpColor );
   ObjectSet("PRC031", OBJPROP_CORNER, 0);
   ObjectSet("PRC031", OBJPROP_XDISTANCE, 765+price.x.offset); // 765
   ObjectSet("PRC031", OBJPROP_YDISTANCE, 210+price.y.offset); 

   ObjectCreate("PRC131", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("PRC131", CloseDir , 40 , "Wingdings" , CloseColor );
   ObjectSet("PRC131", OBJPROP_CORNER, 0);
   ObjectSet("PRC131", OBJPROP_XDISTANCE, 930+price.x.offset); // 765
   ObjectSet("PRC131", OBJPROP_YDISTANCE, 210+price.y.offset); 

//+------------------------------------------------------------------+           
 
   ObjectCreate("PRC032", OBJ_LABEL, win, 0, 0);   // 
   ObjectSetText("PRC032",DoubleToStr( mid ,  Digits ), 15, "Arial Bold", MidColor ); // RANGEBuffer2[0] buf0[0]
   ObjectSet("PRC032", OBJPROP_CORNER, 0);
   ObjectSet("PRC032", OBJPROP_XDISTANCE, 860+price.x.offset);
   ObjectSet("PRC032", OBJPROP_YDISTANCE, 197+price.y.offset);
   
   ObjectCreate("PRC132", OBJ_LABEL, win, 0, 0);   // 
   ObjectSetText("PRC132", MidDir , 15, "Wingdings"  , MidColor ); // RANGEBuffer2[0] buf0[0]
   ObjectSet("PRC132", OBJPROP_CORNER, 0);
   ObjectSet("PRC132", OBJPROP_XDISTANCE, 925+price.x.offset);
   ObjectSet("PRC132", OBJPROP_YDISTANCE, 197+price.y.offset);

//+------------------------------------------------------------------+ 
                                      
   ObjectCreate("PRC034", OBJ_LABEL, win, 0, 0);
   ObjectSetText("PRC034",DoubleToStr( mid1 , Digits ), 15, "Arial Bold", Mid1Color );
   ObjectSet("PRC034", OBJPROP_CORNER, 0);
   ObjectSet("PRC034", OBJPROP_XDISTANCE, 860+price.x.offset);
   ObjectSet("PRC034", OBJPROP_YDISTANCE, 260+price.y.offset); 
      
   ObjectCreate("PRC134", OBJ_LABEL, win, 0, 0);
   ObjectSetText("PRC134", Mid1Dir , 15,  "Wingdings" , Mid1Color );
   ObjectSet("PRC134", OBJPROP_CORNER, 0);
   ObjectSet("PRC134", OBJPROP_XDISTANCE, 925+price.x.offset);
   ObjectSet("PRC134", OBJPROP_YDISTANCE, 260+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="MN1";
   }
   return(tfs);
}
//+------------------------------------------------------------------+  
/*

Big number is the current price.

Arrow to the right tells if price is up or down compared to open.

Top Left = high price

Top Right = current midpoint

Bottom Left = low price

Bottom Right = previous midpoint.

*/