//+------------------------------------------------------------------+
//|                                             !xMeter_EURvsUSD.mq4 |
//|                                        Copyright © 2007, FerruFx |
//|                                                                  |
//|                   Price Meter System™ ©GPL by Rlinac (TSD-forum) |
//|           2007/05/16 Modified by Robert Hill (IBFX mini Account) |
//|                                                                  |
//+------------------------------------------------------------------+

//---- Trade parameters
extern string    Trade_parameters = "=== Trade parameters ===";
extern double    Lot              =         1.0;  // Lot size
extern double    TakeProfit       =         70.0;  // Profit for the order opened
extern double    TrailingStop     =         30.0;  // Pips to trail the StopLoss
extern double    StopLoss         =         50.0;  // StopLoss
extern int       Slippage         =            3;  // Slippage
extern double    HighLevel        =          5.0;  // Level to reach for 1st condition become true
extern double    LowLevel         =          3.0;  // Level to not exceed for 2nd condition become true
extern int       MaxSpread        =          5.0;  // Maximum Spread allowed for trading

//---- Lot size management
extern string    Lot_size_management = "=== Lot size management ===";
extern string    AccountType_is   =    " 0=normal,1=mini,2=micro";
extern int       AccountType      =          0;
extern bool      ManagedLotSize   =        false;  // If true, lot size based on the free margin
extern double    Risk             =          1.0;  // Risk to protect the equity
extern int       MaxLot           =         10.0;  // Maximum lot size

//---- Only for IBFX mini account
extern string    IBFX_mini_account= "=== Only for IBFX mini account ===";
extern bool AccountIsIBFXmini     = false;

//---- !xMeter indicator settings
#define ARRSIZE  12                     // number of pairs !!!DON'T CHANGE THIS NUMBER!!!
#define PAIRSIZE 7                      // number of currencies !!!DON'T CHANGE THIS NUMBER!!!
#define TABSIZE  10                     // scale of currency's power !!!DON'T CHANGE THIS NUMBER!!!
#define ORDER    2                      // available type of order !!!DON'T CHANGE THIS NUMBER!!!
// Currency pair
#define EURUSD 0
#define GBPUSD 1
#define AUDUSD 2
#define USDJPY 3
#define USDCHF 4
#define USDCAD 5
#define EURJPY 6
#define EURGBP 7
#define EURCHF 8
#define EURAUD 9
#define GBPJPY 10
#define GBPCHF 11
// Currency
#define USD 0
#define EUR 1
#define GBP 2
#define CHF 3
#define CAD 4
#define AUD 5
#define JPY 6

string aPair[ARRSIZE]   = {"EURUSDm","GBPUSDm","AUDUSDm","USDJPYm","USDCHFm","USDCADm",
                           "EURJPYm","EURGBPm","EURCHFm","EURAUDm","GBPJPYm","GBPCHFm"};
string aMajor[PAIRSIZE] = {"USD","EUR","GBP","CHF","CAD","AUD","JPY"};
string aOrder[ORDER]    = {"BUY ","SELL "};

double aMeter[PAIRSIZE];
double aHigh[ARRSIZE];
double aLow[ARRSIZE];
double aBid[ARRSIZE];
//double aAsk[ARRSIZE];
double aRatio[ARRSIZE];
double aRange[ARRSIZE];
double aLookup[ARRSIZE];
double aStrength[ARRSIZE];
double point;
int    index;
string mySymbol;

double   sl, tp, lot;
int      MagicNumber, cnt, ticket, total;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   if (Symbol() == "AUDCADm" || Symbol() == "AUDCAD") { MagicNumber = 426801; }
   if (Symbol() == "AUDJPYm" || Symbol() == "AUDJPY") { MagicNumber = 426802; }
   if (Symbol() == "AUDNZDm" || Symbol() == "AUDNZD") { MagicNumber = 426803; }
   if (Symbol() == "AUDUSDm" || Symbol() == "AUDUSD") { MagicNumber = 426804; }
   if (Symbol() == "CHFJPYm" || Symbol() == "CHFJPY") { MagicNumber = 426805; }
   if (Symbol() == "EURAUDm" || Symbol() == "EURAUD") { MagicNumber = 426806; }
   if (Symbol() == "EURCADm" || Symbol() == "EURCAD") { MagicNumber = 426807; }
   if (Symbol() == "EURCHFm" || Symbol() == "EURCHF") { MagicNumber = 426808; }
   if (Symbol() == "EURGBPm" || Symbol() == "EURGBP") { MagicNumber = 426809; }
   if (Symbol() == "EURJPYm" || Symbol() == "EURJPY") { MagicNumber = 426810; }
   if (Symbol() == "EURUSDm" || Symbol() == "EURUSD") { MagicNumber = 426811; }
   if (Symbol() == "GBPCHFm" || Symbol() == "GBPCHF") { MagicNumber = 426812; }
   if (Symbol() == "GBPJPYm" || Symbol() == "GBPJPY") { MagicNumber = 426813; }
   if (Symbol() == "GBPUSDm" || Symbol() == "GBPUSD") { MagicNumber = 426814; }
   if (Symbol() == "NZDJPYm" || Symbol() == "NZDJPY") { MagicNumber = 426815; }
   if (Symbol() == "NZDUSDm" || Symbol() == "NZDUSD") { MagicNumber = 426816; }
   if (Symbol() == "USDCHFm" || Symbol() == "USDCHF") { MagicNumber = 426817; }
   if (Symbol() == "USDJPYm" || Symbol() == "USDJPY") { MagicNumber = 426818; }
   if (Symbol() == "USDCADm" || Symbol() == "USDCAD") { MagicNumber = 426819; }
   if (MagicNumber == 0) { MagicNumber = 426899; }
   
   int   err,lastError;
   initGraph();
   Sleep(10000);
/*   while (true)                                                             // infinite loop for main program
      {
      if (IsConnected()) start();
      if (!IsConnected()) objectBlank();
      WindowRedraw();
      Sleep(1000);                                                          // give your PC a breath
      }
      
*/   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectsDeleteAll(0,OBJ_LABEL);
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {

//---- !xMeter calculation
     
   for (index = 0; index < ARRSIZE; index++)    // initialize all pairs required value 
      {
      RefreshRates();   // refresh all currency's
      if (AccountIsIBFXmini) mySymbol = aPair[index];
      else mySymbol = StringSubstr(aPair[index],0,6);
      //--- point calculation
      if (mySymbol == "USDJPY" || mySymbol == "EURJPY" || mySymbol == "GBPJPY") { point = 0.01; }
      else { point = 0.0001; }
      
      //--- grade table for currency's power
      int aTable[TABSIZE]  = {0,3,10,25,40,50,60,75,90,97};
      if      (aRatio[index]*100 <= aTable[0]) aLookup[index]   = 0;
      else if (aRatio[index]*100 < aTable[1])  aLookup[index]   = 0;
      else if (aRatio[index]*100 < aTable[2])  aLookup[index]   = 1;
      else if (aRatio[index]*100 < aTable[3])  aLookup[index]   = 2;
      else if (aRatio[index]*100 < aTable[4])  aLookup[index]   = 3;
      else if (aRatio[index]*100 < aTable[5])  aLookup[index]   = 4;
      else if (aRatio[index]*100 < aTable[6])  aLookup[index]   = 5;
      else if (aRatio[index]*100 < aTable[7])  aLookup[index]   = 6;
      else if (aRatio[index]*100 < aTable[8])  aLookup[index]   = 7;
      else if (aRatio[index]*100 < aTable[9])  aLookup[index]   = 8;
      else                                     aLookup[index]   = 9;
      //---

      //aHigh[index]     = MarketInfo(mySymbol,MODE_HIGH);                // set a high today
      aHigh[index]     = iHigh(mySymbol,1440,0);
 //Print(aHigh[index]);
      //aLow[index]      = MarketInfo(mySymbol,MODE_LOW);                 // set a low today
      aLow[index]      = iLow(mySymbol,1440,0);
 //Print(aLow[index]);      
      //aBid[index]      = MarketInfo(mySymbol,MODE_BID);                 // set a last bid
      aBid[index]      = iClose(mySymbol,1440,0);
 //Print(aBid[index]);      
      //aAsk[index]      = MarketInfo(mySymbol,MODE_ASK);                 // set a last ask
      
      aRange[index]    = MathMax((aHigh[index]-aLow[index])/point,1);       // calculate range today
      aRatio[index]    = (aBid[index]-aLow[index])/aRange[index]/point;     // calculate pair ratio
      aStrength[index] = 9-aLookup[index];                                  // set a pair strengh
      }   //---- for

   //---- calculate all currencies meter         
   aMeter[USD] = NormalizeDouble((aLookup[USDJPY]+aLookup[USDCHF]+aLookup[USDCAD]+aStrength[EURUSD]+aStrength[GBPUSD]+aStrength[AUDUSD])/6,1);
   aMeter[EUR] = NormalizeDouble((aLookup[EURUSD]+aLookup[EURJPY]+aLookup[EURGBP]+aLookup[EURCHF]+aLookup[EURAUD])/5,1);
   aMeter[GBP] = NormalizeDouble((aLookup[GBPUSD]+aLookup[GBPJPY]+aLookup[GBPCHF]+aStrength[EURGBP])/4,1);
   aMeter[CHF] = NormalizeDouble((aStrength[USDCHF]+aStrength[EURCHF]+aStrength[GBPCHF])/3,1);
   aMeter[CAD] = NormalizeDouble((aStrength[USDCAD]),1);
   aMeter[AUD] = NormalizeDouble((aLookup[AUDUSD]+aStrength[EURAUD])/2,1);
   aMeter[JPY] = NormalizeDouble((aStrength[USDJPY]+aStrength[EURJPY]+aStrength[GBPJPY])/3,1);
        
   //---- display the results     
   objectBlank();   
   paintUSD(aMeter[USD]);
   paintEUR(aMeter[EUR]);
   /*
   paintGBP(aMeter[GBP]);
   paintCHF(aMeter[CHF]);
   paintCAD(aMeter[CAD]);
   paintAUD(aMeter[AUD]);
   paintJPY(aMeter[JPY]);
   paintLine();
   */
   
   double eur = aMeter[EUR];
   double usd = aMeter[USD];
   
//---- Test the variables

   /*
   ObjectCreate("EUR1", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("EUR1",DoubleToStr(eur,1),7, "Verdana", Lime);
   ObjectSet("EUR1", OBJPROP_CORNER, 1);
   ObjectSet("EUR1", OBJPROP_XDISTANCE, 200);
   ObjectSet("EUR1", OBJPROP_YDISTANCE, 50);
   
   ObjectCreate("USD1", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("USD1",DoubleToStr(usd,1),7, "Verdana", Red);
   ObjectSet("USD1", OBJPROP_CORNER, 1);
   ObjectSet("USD1", OBJPROP_XDISTANCE, 200);
   ObjectSet("USD1", OBJPROP_YDISTANCE, 70);
   */
   
//---- GO TRADING

//---- Check if order opened

   total = OrdersTotal();
   int j, orders;
   for(j=0;j<total;j++)
   {
    OrderSelect(j, SELECT_BY_POS, MODE_TRADES);
    if(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol()) orders++; //---- an order is opened with
   }                                                                             //---- same symbol, same magic number
   
   if ( orders < 1 )    //---- we can go trading
   {

//---- Lot size calculation

  if (AccountType==0)
   {
	 if (ManagedLotSize) { lot=NormalizeDouble(AccountBalance()*Risk/10000,1); }
	 else { lot=Lot; }
   } 
   
   if (AccountType==1)
   {  // then is mini
    if (ManagedLotSize) { lot=NormalizeDouble((AccountBalance()*Risk/10000)/10,1); }
	 else { lot=Lot; }
   }
   
   if (AccountType==2)
   {
    if (ManagedLotSize) { lot=NormalizeDouble((AccountBalance()*Risk/10000)/100,1); }
    else { lot=Lot; }
   }

   if (lot<0.01) lot=0.01;
   if (lot>10) lot=10; 
////////////////////////////////////////////////////////////////////////////////////////////////// 
    
//---- Display the spread and EUR/USD's values

    /*
    Comment("\n"+"Current spread: "+spread
           ,"\n"+"EUR value: "+DoubleToStr(eur,1)
           ,"\n"+"USD value: "+DoubleToStr(usd,1));
    */
int spread = MarketInfo(Symbol(),MODE_SPREAD);    
//---- Check for long position
   
    if ( eur >= HighLevel && usd <= LowLevel && spread <= MaxSpread )
    {
     if (TakeProfit==0) { tp=0; }
     else { tp=Ask+TakeProfit*Point; }
     if (StopLoss==0) { sl=0; }
     else { sl=Ask-StopLoss*Point; }
     ticket=OrderSend(Symbol(),OP_BUY,lot,Ask,Slippage,0,0,"!xMeter EURvsUSD",MagicNumber,0,Lime);
     if( ticket > 0 )
     {
      if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
      {
       Print("BUY order opened : ",OrderOpenPrice()); 
       Sleep(1000);
       {OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0,Coral); Alert("EUR buy: ",Period(),"",sl,"",tp,"");
       return(0);
       }
      }
     }
     else
     {
      Print("Error opening BUY order : ",GetLastError()); 
     }
     return(0); 
    }

//---- Check for short position

    if ( usd >= HighLevel && eur <= LowLevel && spread <= MaxSpread ) 
    {
     if (TakeProfit==0) { tp=0; }
     else { tp=Bid-TakeProfit*Point; }
     if (StopLoss==0) { sl=0; }
     else { sl=Bid+StopLoss*Point; }
     ticket=OrderSend(Symbol(),OP_SELL,lot,Bid,Slippage,0,0,"!xMeter EURvsUSD",MagicNumber,0,Red);
     if(ticket>0)
     {
      if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
      {
       Print("SELL order opened : ",OrderOpenPrice());
       Sleep(1000);
       {OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,0,Coral); Alert("EUR sell: ",Period(),"",sl,"",tp,""); 
       return(0);
       }
      }
     }
     else
     {
      Print("Error opening SELL order : ",GetLastError());
     } 
     return(0); 
    }
    return(0);
     
   }
    
   
//---- Check for exit

   total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
   {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber)
    {
     if(OrderType()==OP_BUY)   //---- long position
     {
            
//---- Trailing stop long

      if(TrailingStop>0)  
      {                 
       if(Bid-OrderOpenPrice()>Point*TrailingStop)
       {
        if(OrderStopLoss()<Bid-Point*TrailingStop)
        {
         OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Lime); Alert("EUR mod: ",Period(),"");
         return(0);
        }
       }
      }
     }
     else //---- short position
     {
     
//---- Trailing stop short
            
      if(TrailingStop>0)  
      {                 
       if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
       {
        if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
        {
         OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); Alert("EUR mod: ",Period(),"");
         return(0);
        }
       }
      }
     }      //---- else
    }       //---- if(OrderType()<=OP_SELL &&
   }        //---- for
   
   return(0);
   
  }         //---- int start()


//---- Display the !xMeter's values

void initGraph()
  {
   ObjectsDeleteAll(0,OBJ_LABEL);

   objectCreate("usd_1",30,38);
   objectCreate("usd_2",30,30);
   objectCreate("usd_3",30,22);
   objectCreate("usd_4",30,14);
   objectCreate("usd_5",30,7);
   objectCreate("usd",32,5,"USD",7,"Arial Narrow",SkyBlue);
   objectCreate("usdp",34,16,DoubleToStr(9,1),8,"Arial Narrow",Silver);
   
   objectCreate("eur_1",10,38);
   objectCreate("eur_2",10,30);
   objectCreate("eur_3",10,22);
   objectCreate("eur_4",10,14);
   objectCreate("eur_5",10,7);
   objectCreate("eur",12,5,"EUR",7,"Arial Narrow",SkyBlue);
   objectCreate("eurp",14,16,DoubleToStr(9,1),8,"Arial Narrow",Silver);
/*
   objectCreate("gbp_1",90,43);
   objectCreate("gbp_2",90,35);
   objectCreate("gbp_3",90,27);
   objectCreate("gbp_4",90,19);
   objectCreate("gbp_5",90,11);
   objectCreate("gbp",92,12,"GBP",7,"Arial Narrow",SkyBlue);
   objectCreate("gbpp",94,21,DoubleToStr(9,1),8,"Arial Narrow",Silver);
   
   objectCreate("chf_1",70,43);
   objectCreate("chf_2",70,35);
   objectCreate("chf_3",70,27);
   objectCreate("chf_4",70,19);
   objectCreate("chf_5",70,11);
   objectCreate("chf",72,12,"CHF",7,"Arial Narrow",SkyBlue);
   objectCreate("chfp",74,21,DoubleToStr(9,1),8,"Arial Narrow",Silver);

   objectCreate("cad_1",50,43);
   objectCreate("cad_2",50,35);   
   objectCreate("cad_3",50,27);
   objectCreate("cad_4",50,19);
   objectCreate("cad_5",50,11);
   objectCreate("cad",52,12,"CAD",7,"Arial Narrow",SkyBlue);
   objectCreate("cadp",54,21,DoubleToStr(9,1),8,"Arial Narrow",Silver);
   
   objectCreate("aud_1",30,43);
   objectCreate("aud_2",30,35);
   objectCreate("aud_3",30,27);
   objectCreate("aud_4",30,19);
   objectCreate("aud_5",30,11);
   objectCreate("aud",32,12,"AUD",7,"Arial Narrow",SkyBlue);
   objectCreate("audp",34,21,DoubleToStr(9,1),8,"Arial Narrow",Silver);

   objectCreate("jpy_1",10,43);
   objectCreate("jpy_2",10,35);
   objectCreate("jpy_3",10,27);
   objectCreate("jpy_4",10,19);
   objectCreate("jpy_5",10,11);
   objectCreate("jpy",13,12,"JPY",7,"Arial Narrow",SkyBlue);
   objectCreate("jpyp",14,21,DoubleToStr(9,1),8,"Arial Narrow",Silver);
   
   objectCreate("line",10,6,"-----------------------------------",10,"Arial",DimGray);  
   objectCreate("line1",10,27,"-----------------------------------",10,"Arial",DimGray);  
   objectCreate("line2",10,69,"-----------------------------------",10,"Arial",DimGray);
   objectCreate("sign",11,1,"»»» Price Meter System™ ©GPL «««",8,"Arial Narrow",DimGray);
*/   
   WindowRedraw();
  }
//+------------------------------------------------------------------+
void objectCreate(string name,int x,int y,string text="-",int size=42,
                  string font="Arial",color colour=CLR_NONE)
  {
   ObjectCreate(name,OBJ_LABEL,0,0,0);
   ObjectSet(name,OBJPROP_CORNER,3);
   ObjectSet(name,OBJPROP_COLOR,colour);
   ObjectSet(name,OBJPROP_XDISTANCE,x);
   ObjectSet(name,OBJPROP_YDISTANCE,y);
   ObjectSetText(name,text,size,font,colour);
  }

void objectBlank()
  {
   ObjectSet("usd_1",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("usd_2",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("usd_3",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("usd_4",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("usd_5",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("usd",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("usdp",OBJPROP_COLOR,CLR_NONE);

   ObjectSet("eur_1",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("eur_2",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("eur_3",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("eur_4",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("eur_5",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("eur",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("eurp",OBJPROP_COLOR,CLR_NONE);
/*
   ObjectSet("gbp_1",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("gbp_2",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("gbp_3",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("gbp_4",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("gbp_5",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("gbp",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("gbpp",OBJPROP_COLOR,CLR_NONE);

   ObjectSet("chf_1",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("chf_2",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("chf_3",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("chf_4",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("chf_5",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("chf",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("chfp",OBJPROP_COLOR,CLR_NONE);

   ObjectSet("cad_1",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("cad_2",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("cad_3",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("cad_4",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("cad_5",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("cad",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("cadp",OBJPROP_COLOR,CLR_NONE);

   ObjectSet("aud_1",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("aud_2",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("aud_3",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("aud_4",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("aud_5",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("aud",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("audp",OBJPROP_COLOR,CLR_NONE);

   ObjectSet("jpy_1",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("jpy_2",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("jpy_3",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("jpy_4",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("jpy_5",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("jpy",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("jpyp",OBJPROP_COLOR,CLR_NONE);
   
   ObjectSet("line1",OBJPROP_COLOR,CLR_NONE);
   ObjectSet("line2",OBJPROP_COLOR,CLR_NONE); 
*/
  }
  
void paintUSD(double value)
  {
   if (value > 0) ObjectSet("usd_5",OBJPROP_COLOR,Red);
   if (value > 2) ObjectSet("usd_4",OBJPROP_COLOR,Orange);
   if (value > 4) ObjectSet("usd_3",OBJPROP_COLOR,Gold);   
   if (value > 6) ObjectSet("usd_2",OBJPROP_COLOR,YellowGreen);
   if (value > 7) ObjectSet("usd_1",OBJPROP_COLOR,Lime);
   ObjectSet("usd",OBJPROP_COLOR,SkyBlue);
   ObjectSetText("usdp",DoubleToStr(value,1),8,"Arial Narrow",Silver);
  }

void paintEUR(double value)
  {
   if (value > 0) ObjectSet("eur_5",OBJPROP_COLOR,Red);
   if (value > 2) ObjectSet("eur_4",OBJPROP_COLOR,Orange);
   if (value > 4) ObjectSet("eur_3",OBJPROP_COLOR,Gold);   
   if (value > 6) ObjectSet("eur_2",OBJPROP_COLOR,YellowGreen);
   if (value > 7) ObjectSet("eur_1",OBJPROP_COLOR,Lime);
   ObjectSet("eur",OBJPROP_COLOR,SkyBlue);
   ObjectSetText("eurp",DoubleToStr(value,1),8,"Arial Narrow",Silver);
  }
/*
void paintGBP(double value)
  {
   if (value > 0) ObjectSet("gbp_5",OBJPROP_COLOR,Red);
   if (value > 2) ObjectSet("gbp_4",OBJPROP_COLOR,Orange);
   if (value > 4) ObjectSet("gbp_3",OBJPROP_COLOR,Gold);   
   if (value > 6) ObjectSet("gbp_2",OBJPROP_COLOR,YellowGreen);
   if (value > 7) ObjectSet("gbp_1",OBJPROP_COLOR,Lime);
   ObjectSet("gbp",OBJPROP_COLOR,SkyBlue);
   ObjectSetText("gbpp",DoubleToStr(value,1),8,"Arial Narrow",Silver);
  }

void paintCHF(double value)
  {
   if (value > 0) ObjectSet("chf_5",OBJPROP_COLOR,Red);
   if (value > 2) ObjectSet("chf_4",OBJPROP_COLOR,Orange);
   if (value > 4) ObjectSet("chf_3",OBJPROP_COLOR,Gold);   
   if (value > 6) ObjectSet("chf_2",OBJPROP_COLOR,YellowGreen);
   if (value > 7) ObjectSet("chf_1",OBJPROP_COLOR,Lime);
   ObjectSet("chf",OBJPROP_COLOR,SkyBlue);
   ObjectSetText("chfp",DoubleToStr(value,1),8,"Arial Narrow",Silver);
  }

void paintCAD(double value)
  {
   if (value > 0) ObjectSet("cad_5",OBJPROP_COLOR,Red);
   if (value > 2) ObjectSet("cad_4",OBJPROP_COLOR,Orange);
   if (value > 4) ObjectSet("cad_3",OBJPROP_COLOR,Gold);   
   if (value > 6) ObjectSet("cad_2",OBJPROP_COLOR,YellowGreen);
   if (value > 7) ObjectSet("cad_1",OBJPROP_COLOR,Lime);
   ObjectSet("cad",OBJPROP_COLOR,SkyBlue);
   ObjectSetText("cadp",DoubleToStr(value,1),8,"Arial Narrow",Silver);
  }

void paintAUD(double value)
  {
   if (value > 0) ObjectSet("aud_5",OBJPROP_COLOR,Red);
   if (value > 2) ObjectSet("aud_4",OBJPROP_COLOR,Orange);
   if (value > 4) ObjectSet("aud_3",OBJPROP_COLOR,Gold);   
   if (value > 6) ObjectSet("aud_2",OBJPROP_COLOR,YellowGreen);
   if (value > 7) ObjectSet("aud_1",OBJPROP_COLOR,Lime);
   ObjectSet("aud",OBJPROP_COLOR,SkyBlue);
   ObjectSetText("audp",DoubleToStr(value,1),8,"Arial Narrow",Silver);
  }

void paintJPY(double value)
  {
   if (value > 0) ObjectSet("jpy_5",OBJPROP_COLOR,Red);
   if (value > 2) ObjectSet("jpy_4",OBJPROP_COLOR,Orange);
   if (value > 4) ObjectSet("jpy_3",OBJPROP_COLOR,Gold);   
   if (value > 6) ObjectSet("jpy_2",OBJPROP_COLOR,YellowGreen);
   if (value > 7) ObjectSet("jpy_1",OBJPROP_COLOR,Lime);
   ObjectSet("jpy",OBJPROP_COLOR,SkyBlue);
   ObjectSetText("jpyp",DoubleToStr(value,1),8,"Arial Narrow",Silver);
  }
  
void paintLine()
  {
   ObjectSet("line1",OBJPROP_COLOR,DimGray);
   ObjectSet("line2",OBJPROP_COLOR,DimGray);
  }
*/  

