// +------------------------------------------------------------------------------------------+ //
// |    .-._______                           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 FOREX POWER.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

color          PanelColor1       = C'144,144,144';
color          PanelColor2       = C'22,22,22';
bool           show.panel        = true;
int            Shift.up.down     = 0;
int            Shift.sideway     = -3;


int X = 26;
int Y = 55;
extern int Corner = 0;
extern int window = 0;
int fontsize = 12;
string font = "MV Boli";


#define ID_USD  0
#define ID_GBP  1
#define ID_CHF  2
#define ID_AUD  3
#define ID_JPY  4
#define N_CROSS 5

string SingolaValuta[] = {"USD", 
                          "GBP", 
                          "CHF", 
                          "AUD",
                          "JPY"};
                    
string CoppiaValuta[] = {"USDCHF", 
                         "GBPUSD",
                         "AUDUSD", 
                         "AUDCHF", 
                         "GBPCHF", 
                         "GBPAUD",
                         "AUDJPY",
                         "CHFJPY",
                         "GBPJPY",
                         "USDJPY"};
string space = "";
string NomeIndi;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   NomeIndi = WindowExpertName();
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
  for (int i = 0; i <= ArraySize(SingolaValuta)*2; i++) 
  {    
       ObjectDelete(SingolaValuta[i]+"_val");
       ObjectDelete(SingolaValuta[i]+"_nom");
       ObjectDelete(SingolaValuta[i]+"_pos");
       ObjectDelete("AABoxXX2-1");
       ObjectDelete("AABoxXX2-2");
       ObjectDelete("AABoxXX2-3");
       ObjectDelete("AABoxXX2-4");
       ObjectDelete("AABoxXX2-5");
       ObjectDelete("AABoxXX2-6");
       ObjectDelete("AAObj11d");
   }
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();

   if(show.panel){
   
   CreateXX2_Labels( "AABoxXX2-1",7,29); 
   ObjectSetText("AABoxXX2-1", "gg", 48, "Webdings", PanelColor1);
   
   CreateXX2_Labels( "AABoxXX2-2",7,77); 
   ObjectSetText("AABoxXX2-2", "gg", 48, "Webdings", PanelColor1);
   
   
   
   CreateXX2_Labels( "AABoxXX2-4",9,32); 
   ObjectSetText("AABoxXX2-4", "gg", 47, "Webdings", PanelColor2);
   
   CreateXX2_Labels( "AABoxXX2-5",9,78); 
   ObjectSetText("AABoxXX2-5", "gg", 47, "Webdings", PanelColor2);
   
   
   
   }
     
   displayMeter();
   
   ObjectDelete("AAObj11d");
   ObjectCreate("AAObj11d", OBJ_LABEL, window, 0, 0);
   ObjectSetText("AAObj11d", "FOREX POWER" , 12, "Courier New Bold", Snow);
   ObjectSet("AAObj11d", OBJPROP_CORNER, Corner);
   ObjectSet("AAObj11d", OBJPROP_XDISTANCE, X-13);
   ObjectSet("AAObj11d", OBJPROP_YDISTANCE, Y-17);

   return(0);
  }
  
//+------------------------------------------------------------------+
//| displayMeter function                                            |
//+------------------------------------------------------------------+
void displayMeter() 
   {

   double ValoreZero[N_CROSS,2];
   color  ColoreZero[N_CROSS,2];
   
   ValoreZero[ID_USD,0] = currency_strength(SingolaValuta[ID_USD]);
   ValoreZero[ID_GBP,0] = currency_strength(SingolaValuta[ID_GBP]);
   ValoreZero[ID_CHF,0] = currency_strength(SingolaValuta[ID_CHF]);
   ValoreZero[ID_AUD,0] = currency_strength(SingolaValuta[ID_AUD]);
   ValoreZero[ID_JPY,0] = currency_strength(SingolaValuta[ID_JPY]);
   
   
   ValoreZero[ID_USD,1] = ID_USD;  //1
   ValoreZero[ID_GBP,1] = ID_GBP;  //3
   ValoreZero[ID_CHF,1] = ID_CHF;  //5
   ValoreZero[ID_AUD,1] = ID_AUD;  //8
   ValoreZero[ID_JPY,1] = ID_JPY;  //8
   

   ArraySort(ValoreZero,WHOLE_ARRAY,0,MODE_DESCEND);
   
   int win = WindowFind(NomeIndi);
 
   int j,Y2=Y;
   
   for(int i=0; i<N_CROSS; i++)
   {
      j = ValoreZero[i,1];
      objectCreate(SingolaValuta[j]+"_pos", Corner, X-10, Y2, 0,( i+1)+". ", fontsize, font, symcolor(ValoreZero[i,0]));
      objectCreate(SingolaValuta[j]+"_nom", Corner, X+10, Y2, 0, SingolaValuta[j], fontsize, font, symcolor(ValoreZero[i,0]));
      objectCreate(SingolaValuta[j]+"_val", Corner, X+55, Y2, 0, DoubleToStr(ValoreZero[i,0],2), fontsize, font, symcolor(ValoreZero[i,0]));
      Y2 += 15;
   }
   
   
}

//+------------------------------------------------------------------+
//| symcolor function                                                |
//+------------------------------------------------------------------+
int symcolor(double ad_0) {
   int li_ret_8;
   if (ad_0 <= 2.0) li_ret_8 = White;
   if (ad_0 > 2.0) li_ret_8 =  White;
   if (ad_0 >= 7.0) li_ret_8 = White;
   return (li_ret_8);
}

   

//+------------------------------------------------------------------+
//| currency_strength function                                       |
//+------------------------------------------------------------------+
double currency_strength(string couple) {
   int index;
   string Pair;
   double HiLo;
   double ld_28;
   double ld_ret_36 = 0;
   int cnt = 0;
   for (int i = 0; i < ArraySize(CoppiaValuta); i++) {
      index = 0;
      Pair = CoppiaValuta[i];
      if (couple == StringSubstr(Pair, 0, 3) || couple == StringSubstr(Pair, 3, 3)) {
         Pair = Pair + space;
         HiLo = (MarketInfo(Pair, MODE_HIGH) - MarketInfo(Pair, MODE_LOW)) * MarketInfo(Pair, MODE_POINT);
         if (HiLo != 0.0) {
            ld_28 = 100.0 * ((MarketInfo(Pair, MODE_BID) - MarketInfo(Pair, MODE_LOW)) / HiLo * MarketInfo(Pair, MODE_POINT));
            if (ld_28 >  3.0) index = 1;
            if (ld_28 > 10.0) index = 2;
            if (ld_28 > 25.0) index = 3;
            if (ld_28 > 40.0) index = 4;
            if (ld_28 > 50.0) index = 5;
            if (ld_28 > 60.0) index = 6;
            if (ld_28 > 75.0) index = 7;
            if (ld_28 > 90.0) index = 8;
            if (ld_28 > 97.0) index = 9;
            cnt++;
            if (couple == StringSubstr(Pair, 3, 3)) index = 9 - index;
            ld_ret_36 += index;
         }
      }
   }
   ld_ret_36 /= cnt;
   return (ld_ret_36);
   
   
}

//+------------------------------------------------------------------+
//| objectCreate function                                            |
//+------------------------------------------------------------------+
void objectCreate(string nome, int angolo, int val_x, int val_y, int val_ang, string testo = "-", int fontsize = 42, string fontname = "Arial", color color1 = -1)/* colore1 = -1)*/
   {
   if (ObjectFind(nome) != 0) {
      ObjectCreate(nome, OBJ_LABEL, window, 0, 0);
      ObjectSet(nome, OBJPROP_CORNER, angolo);
      ObjectSet(nome, OBJPROP_COLOR, color1);
      ObjectSet(nome, OBJPROP_BACK, 0);
      ObjectSet(nome, OBJPROP_XDISTANCE, val_x);
      ObjectSet(nome, OBJPROP_YDISTANCE, val_y);
      ObjectSet(nome, OBJPROP_ANGLE, val_ang);
      ObjectSetText(nome, testo, fontsize, fontname, color1);
      return;
   }
   ObjectSet(nome, OBJPROP_CORNER, angolo);
   ObjectSet(nome, OBJPROP_COLOR, color1);
   ObjectSet(nome, OBJPROP_BACK, 0);
   ObjectSet(nome, OBJPROP_XDISTANCE, val_x);
   ObjectSet(nome, OBJPROP_YDISTANCE, val_y);
   ObjectSet(nome, OBJPROP_ANGLE, val_ang);
   ObjectSetText(nome, testo, fontsize, fontname, color1);
   }
   
   int CreateXX2_Labels( string bj, int xj, int yj ) {
   ObjectCreate( bj, OBJ_LABEL, 0, 0, 0 );
   ObjectSet( bj, OBJPROP_CORNER, 0 );
   ObjectSet( bj, OBJPROP_XDISTANCE,xj+Shift.sideway);
   ObjectSet( bj, OBJPROP_YDISTANCE,yj+Shift.up.down);
   ObjectSet( bj, OBJPROP_BACK, 0 );
   }
// ------------------------------------------------------------------------------------------ //
//                                     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 3eeed$$b    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@$$$$"         
                                                                  ^$$$*/