// +------------------------------------------------------------------------------------------+ //
// |    .-._______                           XARD777                            _______.-.    | //
// |---( )_)______)                 Knowledge of the ancients                  (______(_( )---| //
// |  (    ()___)                              \�/                               (___()    )  | //
// |       ()__)                              (o o)                               (__()       | //
// |--(___()_)__________________________oOOo___(_)___oOOo___________________________(_()___)--| //
// |______|______|______|______|______|______|______|______|______|______|______|______|______| //
// |___|______|_Cam__|______|______|______|______|______|______|______|Ismael|______|______|__| //
// |______|______|______|______|______|______|__Big_Joe____|______|______|______|______|______| //
// |___|______|______|______|_Mundu|______|______|______|______|______|______|______|______|__| //
// |______|__cja_|______|______|______|__Hendrik____|______|______|______|______|______|______| //
// |___|______|______|______|______|______|______|______|Tzuman|______|______|______|______|__| //
// |______|______|______|Hercs_|______|______|______|______|______|______|Joy22_|______|______| //
// |___|______|______|______|______|______|___Poruchik__|______|______|______|______|______|__| //
// |______|___Pava_the_Clown___|______|______|______|______|__Leledc_____|______|______|_Xard_| //
// |                                                                                     2011 | //
// |                 File:     !XPS v8 PRICE.mq4                                              | //
// | Programming language:     MQL4                                                           | //
// | Development platform:     MetaTrader 4                                                   | //
// |          End product:     THIS SOFTWARE IS FOR FOREX TRADERS                             | //
// |                                                                                          | //
// |                                                                                          | //
// |     Online Resources:     http://search4metatrader.com/index.php                         | //
// |                           www.2bgoogle.com/forex4.html                                   | //
// |                           www.forex-tsd.com                                              | //
// |                           www.forexstrategiesresources.com                               | //
// |                           www.traderszone.com                                            | //
// |                           http://fxcoder.ru/indicators                                   | //
// |                           www.worldwide-invest.org/                                      | //
// |                           http://indo-investasi.com                                      | //
// |                                                                                          | //
// |                                                           [Xard777 Proprietory Software] | //
// +------------------------------------------------------------------------------------------+ //

#property indicator_chart_window
#property  indicator_buffers 1
#property  indicator_color1  CLR_NONE

// ------------------------------------------------------------------------------------------ //
//                            E X T E R N A L   V A R I A B L E S                             //
// ------------------------------------------------------------------------------------------ //

string Part3                          = "PriceLabel Settings:";
color  PriceLabel_StaticColor         = White;
color  PriceLabel_UPColor             = White;
color  PriceLabel_DOWNColor           = White;
string PriceLabel_FontStyle           = "Arial Bold";
int    PriceLabel_FontSize            = 32;
int    PriceLabel_ShiftRight          = 0;
int    PriceLabel_ShiftUpDown         = 10;

// ------------------------------------------------------------------------------------------ //
//                            I N T E R N A L   V A R I A B L E S                             //
// ------------------------------------------------------------------------------------------ //

bool   Indicator_On                   = true;
string _                              = "";
string Part1                          = "General Inputs:";
bool   Use_For_Forex                  = true;
bool   Show_LineLabel                 = false;
bool   Show_PriceLabel                = true;
bool   Show_TimerLabel                = false;
string __                             = "";
string Part2                          = "LineLabel Settings:";
color  LineLabel_Color                = Red;
int    LineLabel_Length               = 06;
int    LineLabel_ShiftRight           = 25;
int    LineLabel_ShiftUpDown          = 12; 
string ___                            = ""; 
string ____                           = "";
string Part4                          = "TimerLabel Settings:";
color  TimerLabel_Color               = Gold;
string TimerLabel_FontStyle           = "Arial Bold";
int    TimerLabel_FontSize            = 15;
int    TimerLabel_ShiftRight          = 18; // 21, 35 and 48 
int    TimerLabel_ShiftUpDown         = 0;
int    whatwindow                     = 0;
int      fxDigits;
double   Old_Price, scale, gi_88;
string   Price;

// ------------------------------------------------------------------------------------------ //
//                             I N I T I A L I S A T I O N                                    //
// ------------------------------------------------------------------------------------------ //

int init()
   {
   if (Use_For_Forex)  {string sub=StringSubstr(Symbol(), 3, 3);
   if (sub == "JPY") {fxDigits = 2;} 
   else if(Symbol()=="XAGUSD" || Symbol()=="XAGUSD"){ fxDigits = 2; }
   else {fxDigits = 4;}}
   return(0);
   }
   
   
  // if (StringFind (Symbol(), "JPY", 0) != -1){ DecNos = 2;}
  // else if(Symbol()=="XAUUSD" || Symbol()=="XAGUSD"){ DecNos = 2; }
  // else { DecNos = 4; }
// ------------------------------------------------------------------------------------------ //
//                            D E - I N I T I A L I S A T I O N                               //
// ------------------------------------------------------------------------------------------ //

int deinit()
   {  
   int obj_total= ObjectsTotal();  
   for (int k= obj_total; k>=0; k--) {
      string name= ObjectName(k);
      if (StringSubstr(name,0,8)=="[BidLine") {ObjectDelete(name);}}    
   }  

// ------------------------------------------------------------------------------------------ //
//                                M A I N   P R O C E D U R E                                 //
// ------------------------------------------------------------------------------------------ //

int start()
   {	
   //Clear chart, turn off or proceed 
   deinit();if (Indicator_On == false) {return(0);}  
   scale = WindowPriceMax() - WindowPriceMin();	
   
   if(Show_LineLabel){
      //Get x,y co-ordinates for BidLine
      double xb = Time[0];
      double yb = Bid + ((scale/400) * LineLabel_ShiftUpDown);
      //Prepare text for BidLine
      string pointer = "[BidLine] Pointer";
      string Tab0; for(int i=1; i<=LineLabel_Length; i++) {Tab0 = Tab0 + "_";}  
      string Tab1; for( i=1; i<=LineLabel_ShiftRight; i++) {Tab1 = Tab1 + " ";} 
      string Text1 = Tab1 + Tab0;  //0,8 and 7,10  
      //Construct/move BidLine       
      if(ObjectFind(pointer) != 0){
         ObjectCreate(pointer, OBJ_TEXT, 0, xb, yb);
         ObjectSetText(pointer, Text1, 16, "Arial Bold", LineLabel_Color);}
      else {ObjectMove(pointer, 0, xb, yb);}}

// ------------------------------------------------------------------------------------------ //
      
   if(Show_PriceLabel){
      //Get x,y co-ordinates for PriceLabel
      double xp = Time[0];
      double yp = Bid + ((scale/400) * PriceLabel_ShiftUpDown);    	
      //Assign the Price & Colors
      int Color = PriceLabel_StaticColor; 
      if (Bid > Old_Price) {Color = PriceLabel_UPColor;}
      if (Bid < Old_Price) {Color = PriceLabel_DOWNColor;}
      Old_Price=Bid;    
      //Define the standard digits used for Price
      if (Use_For_Forex) {Price=DoubleToStr(Bid, fxDigits);}
      else {Price=DoubleToStr(Bid, Digits);}  
      //Prepare text for PriceLabel 
      string price = "[BidLine] Price";
      string Tab2; for(i=1; i<=PriceLabel_ShiftRight; i++) {Tab2 = Tab2 + " ";} 
      string Text2 = Tab2 + "             " + Price; //15       
      //Construct/move PriceLabel                     
      if(ObjectFind(price) != 0){
         ObjectCreate(price, OBJ_TEXT, 0, xp, yp);
         ObjectSetText(price, Text2, PriceLabel_FontSize, PriceLabel_FontStyle, Color);}
      else {ObjectMove(price, 0, xp, yp);}}   

// ------------------------------------------------------------------------------------------ //
   
   if (Show_TimerLabel){
      //Get time (H/M/S) remaining on current candle		
   	int h,m,s,t;    
      t=Time[0]+(Period()*60)-CurTime();
      s=t%60; string seconds = (s); if (s<10) {seconds = ("0"+seconds);} 
      m=(t-t%60)/60;   
      for(i=0; i<24; i++){
         if(m>=60){m=m-60;h=h+1;}
         string minutes = (m); if (m<10) {minutes = ("0"+minutes);}   
         string hours = (h); if (h<10) {hours = ("0"+hours);} 
         string timeleft = (minutes+":"+seconds);
         if (h>=1) {timeleft = (hours+":"+minutes+":"+seconds);}
         if (Period()>1440){timeleft = "OFF";}}                 
      //Get x,y co-ordinates for TimerLabel
      double xt = Time[0];
	   double yt = Bid + ((scale/1000) * TimerLabel_ShiftUpDown);
	   //Prepare text for TimerLabel
	   string bartimer = "[BidLine] Timer";
   	string tab3 = "  ";
	   if(Symbol()== "USDJPY"){tab3= "";}
	   if(Symbol()== "CHFJPY"){tab3= "";}
	   if(Symbol()== "AUDJPY"){tab3= "";}
	   if(Symbol()== "CADJPY"){tab3= "";}
	   if(Symbol()== "XAGJPY"){tab3= "";}	   
	   tab3= tab3 + "       ";
	   if (h>0) {tab3 = StringSubstr(tab3,5);}	
      for(i=0; i<=TimerLabel_ShiftRight; i++){tab3 = tab3 + " ";}  
      string Text3 = tab3 + timeleft;  
      string extra = "                   ";        
      //Construct/move TimerLabel  
      if(ObjectFind(bartimer) != 0){
         ObjectCreate(bartimer,OBJ_TEXT, 0, xt, yt);
         ObjectSetText(bartimer, Text3 , TimerLabel_FontSize, TimerLabel_FontStyle, TimerLabel_Color);}
      else{ObjectMove(bartimer, 0, xt, yt);}}            	   	          
                           
   return(0);//Finished
   }
// ------------------------------------------------------------------------------------------ //
//                                     E N D   P R O G R A M                                  //
// ------------------------------------------------------------------------------------------ //
/*                                                         
                                        ud$$$**BILLION$bc.                          
                                    u@**"        PROJECT$$Nu                       
                                  J                ""#$$$$$$r                     
                                 @                       $$$$b                    
                               .F                        ^*3$$$                   
                              :% 4                         J$$$N                  
                              $  :F                       :$$$$$                  
                             4F  9                       J$$$$$$$                 
                             4$   k             4$$$$bed$$$$$$$$$                 
                             $$r  'F            $$$$$$$$$$$$$$$$$r                
                             $$$   b.           $$$$$$$$$$$$$$$$$N                
                             $$$$$k 3eeedXPS    XARD777."$$$$$$$$$                
              .@$**N.        $$$$$" $$$$$$F'L $$$$$$$$$$$  $$$$$$$                
              :$$L  'L       $$$$$ 4$$$$$$  * $$$$$$$$$$F  $$$$$$F         edNc   
             @$$$$N  ^k      $$$$$  3$$$$*%   $F4$$$$$$$   $$$$$"        d"  z$N  
             $$$$$$   ^k     '$$$"   #$$$F   .$  $$$$$c.u@$$$          J"  @$$$$r 
             $$$$$$$b   *u    ^$L            $$  $$$$$$$$$$$$u@       $$  d$$$$$$ 
              ^$$$$$$.    "NL   "N. z@*     $$$  $$$$$$$$$$$$$P      $P  d$$$$$$$ 
                 ^"*$$$$b   '*L   9$E      4$$$  d$$$$$$$$$$$"     d*   J$$$$$r   
                      ^$$$$u  '$.  $$$L     "#" d$$$$$$".@$$    .@$"  z$$$$*"     
                        ^$$$$. ^$N.3$$$       4u$$$$$$$ 4$$$  u$*" z$$$"          
                          '*$$$$$$$$ *$b      J$$$$$$$b u$$P $"  d$$P             
                             #$$$$$$ 4$ 3*$"$*$ $"$'c@@$$$$ .u@$$$P               
                               "$$$$  ""F~$ $uNr$$$^&J$$$$F $$$$#                 
                                 "$$    "$$$bd$.$W$$$$$$$$F $$"                   
                                   ?k         ?$$$$$$$$$$$F'*                     
                                    9$$bL     z$$$$$$$$$$$F                       
                                     $$$$    $$$$$$$$$$$$$                        
                                      '#$$c  '$$$$$$$$$"                          
                                       .@"#$$$$$$$$$$$$b                          
                                     z*      $$$$$$$$$$$$N.                       
                                   e"      z$$"  #$$$k  '*$$.                     
                                .u*      u@$P"      '#$$c   "$$c                   
                        u@$*"""       d$$"            "$$$u  ^*$$b.               
                      :$F           J$P"                ^$$$c   '"$$$$$$bL        
                     d$$  ..      @$#                      #$$b         '#$       
                     9$$$$$$b   4$$                          ^$$k         '$      
                      "$$6""$b u$$                             '$    d$$$$$P      
                        '$F $$$$$"                              ^b  ^$$$$b$       
                         '$W$$$$"                                'b@$$$$"         
                                                                  ^$$$*/