//+------------------------------------------------------------------+
//|                                                      Complex.mq4 |
//|                                              SemSemFX@rambler.ru |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "SemSemFX@rambler.ru"
#property link      ""

#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Green
#property indicator_color2 Navy
#property indicator_color3 Red
#property indicator_color4 Black
#property indicator_color5 Maroon
#property indicator_color6 Silver
//---- buffers
double USD[];
double EUR[];
double GBP[];
double CHF[];
double JPY[];
double CAD[];
extern int per1=14;
extern int D=3;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorShortName("USD:Green; EUR:Blue; GBP:Red; CHF:Black; JPY:Brown; CAD:Silver");
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,USD);
   SetIndexLabel(0, "USD"); 
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,EUR);
   SetIndexLabel(1, "EUR"); 
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,GBP);
   SetIndexLabel(2, "GBP"); 
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,CHF);
   SetIndexLabel(3, "CHF"); 
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,JPY);
   SetIndexLabel(4, "JPY");
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(5,CAD);
   SetIndexLabel(5, "CAD");  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
     int limit;
     int counted_bars=IndicatorCounted();
  //---- проверка на возможные ошибки
     if(counted_bars<0) return(-1);
  //---- последний посчитанный бар будет пересчитан
     if(counted_bars>0) counted_bars-=10;
     limit=Bars-counted_bars;
  //---- основной цикл
      int Price=6;
      int Mode=3;
      //int per1=13;
      //int per2=5;
     for(int i=0; i<limit; i++)
       {
        USD[i]=
            (iMA("EURUSD",0,per1,0,Mode,Price,i+D)-
            iMA("EURUSD",0,per1,0,Mode,Price,i))*10000
            +
            (iMA("GBPUSD",0,per1,0,Mode,Price,i+D)-
            iMA("GBPUSD",0,per1,0,Mode,Price,i))*10000
            +
            (iMA("USDCHF",0,per1,0,Mode,Price,i)-
            iMA("USDCHF",0,per1,0,Mode,Price,i+D))*10000
            +
            (iMA("USDJPY",0,per1,0,Mode,Price,i)-
            iMA("USDJPY",0,per1,0,Mode,Price,i+D))*100
            +
            (iMA("USDCAD",0,per1,0,Mode,Price,i)-
            iMA("USDCAD",0,per1,0,Mode,Price,i+D))*10000
            ;
        EUR[i]=
            (iMA("EURUSD",0,per1,0,Mode,Price,i)-
            iMA("EURUSD",0,per1,0,Mode,Price,i+D))*10000
            +
            (iMA("EURGBP",0,per1,0,Mode,Price,i)-
            iMA("EURGBP",0,per1,0,Mode,Price,i+D))*10000
            +
            (iMA("EURCHF",0,per1,0,Mode,Price,i)-
            iMA("EURCHF",0,per1,0,Mode,Price,i+D))*10000
            +
            (iMA("EURJPY",0,per1,0,Mode,Price,i)-
            iMA("EURJPY",0,per1,0,Mode,Price,i+D))*100
            +
            (iMA("EURCAD",0,per1,0,Mode,Price,i)-
            iMA("EURCAD",0,per1,0,Mode,Price,i+D))*10000
            ;
        GBP[i]=
            (iMA("GBPUSD",0,per1,0,Mode,Price,i)-
            iMA("GBPUSD",0,per1,0,Mode,Price,i+D))*10000
            +
            (iMA("EURGBP",0,per1,0,Mode,Price,i+D)-
            iMA("EURGBP",0,per1,0,Mode,Price,i))*10000
            +
            (iMA("GBPCHF",0,per1,0,Mode,Price,i)-
            iMA("GBPCHF",0,per1,0,Mode,Price,i+D))*10000
            +
            (iMA("GBPJPY",0,per1,0,Mode,Price,i)-
            iMA("GBPJPY",0,per1,0,Mode,Price,i+D))*100
            +
            (iMA("GBPCAD",0,per1,0,Mode,Price,i)-
            iMA("GBPCAD",0,per1,0,Mode,Price,i+D))*10000
            ;
        CHF[i]=
            (iMA("USDCHF",0,per1,0,Mode,Price,i+D)-
            iMA("USDCHF",0,per1,0,Mode,Price,i))*10000
            +
            (iMA("EURCHF",0,per1,0,Mode,Price,i+D)-
            iMA("EURCHF",0,per1,0,Mode,Price,i))*10000
            +
            (iMA("GBPCHF",0,per1,0,Mode,Price,i+D)-
            iMA("GBPCHF",0,per1,0,Mode,Price,i))*10000
            +
            (iMA("CHFJPY",0,per1,0,Mode,Price,i)-
            iMA("CHFJPY",0,per1,0,Mode,Price,i+D))*100
            +
            (iMA("CADCHF",0,per1,0,Mode,Price,i)-
            iMA("CADCHF",0,per1,0,Mode,Price,i+D))*10000
            ;
        JPY[i]=
            (iMA("USDJPY",0,per1,0,Mode,Price,i+D)-
            iMA("USDJPY",0,per1,0,Mode,Price,i))*100
            +
            (iMA("EURJPY",0,per1,0,Mode,Price,i+D)-
            iMA("EURJPY",0,per1,0,Mode,Price,i))*100
            +
            (iMA("GBPJPY",0,per1,0,Mode,Price,i+D)-
            iMA("GBPJPY",0,per1,0,Mode,Price,i))*100
            +
            (iMA("CHFJPY",0,per1,0,Mode,Price,i+D)-
            iMA("CHFJPY",0,per1,0,Mode,Price,i))*100
            +
            (iMA("CADJPY",0,per1,0,Mode,Price,i)-
            iMA("CADJPY",0,per1,0,Mode,Price,i+D))*100
            ;
         CAD[i]=
            (iMA("USDCAD",0,per1,0,Mode,Price,i)-
            iMA("USDCAD",0,per1,0,Mode,Price,i+D))*10000
            +
            (iMA("EURCAD",0,per1,0,Mode,Price,i+D)-
            iMA("EURCAD",0,per1,0,Mode,Price,i))*10000
            +
            (iMA("CADCHF",0,per1,0,Mode,Price,i)-
            iMA("CADCHF",0,per1,0,Mode,Price,i+D))*10000
            +
            (iMA("CADJPY",0,per1,0,Mode,Price,i)-
            iMA("CADJPY",0,per1,0,Mode,Price,i+D))*100
            +
            (iMA("GBPCAD",0,per1,0,Mode,Price,i)-
            iMA("GBPCAD",0,per1,0,Mode,Price,i+D))*10000
            ;
         //double Summa=USD[i]+EUR[i]+GBP[i]+CHF[i]+JPY[i];
         //Print("Summa: ",Summa);
       }
  //----
    return(0);
  }
//+------------------------------------------------------------------+