//+-------------------------------------------------------------------------+
//|                                                        Index_RSI_MA.mq4 |
//+-------------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Aqua
#property indicator_color2 RoyalBlue
#property indicator_color3 Red
#property indicator_color4 LightGray
#property indicator_color5 Violet
#property indicator_color6 Coral
#property indicator_color7 Yellow
#property indicator_color8 Lime

#property indicator_level1 10
#property indicator_level2 50
#property indicator_level3 90
#property indicator_minimum 0
#property indicator_maximum 100

//---- Внешние параметры

extern int PeriodRSI=5;
extern int Smooth=4;
extern int PeriodEMA=24; // Первичное сглаживание - период

extern int window=1;
extern bool EconomНistori=true; 

//---- Буферы индикатора
double IndexBuffer[],Buffer[],RSIBuffer[];
double IndexBuffer1[],Buffer1[],RSIBuffer1[];
double IndexBuffer2[],Buffer2[],RSIBuffer2[];
double IndexBuffer3[],Buffer3[],RSIBuffer3[];
double IndexBuffer4[],Buffer4[],RSIBuffer4[];
double IndexBuffer5[],Buffer5[],RSIBuffer5[];
double IndexBuffer6[],Buffer6[],RSIBuffer6[];
double IndexBuffer7[],Buffer7[],RSIBuffer7[];
//---- Переменные
int BarsMin,Barsi[7],indBars,bar;datetime time;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,RSIBuffer);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(1,RSIBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(2,RSIBuffer2);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(3,RSIBuffer3);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(4,RSIBuffer4);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(5,RSIBuffer5);
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(6,RSIBuffer6);
   SetIndexStyle(6,DRAW_LINE);
   SetIndexBuffer(7,RSIBuffer7);
   SetIndexStyle(7,DRAW_LINE);

   ArraySetAsSeries(IndexBuffer,true);
   ArraySetAsSeries(IndexBuffer1,true);
   ArraySetAsSeries(IndexBuffer2,true);
   ArraySetAsSeries(IndexBuffer3,true);
   ArraySetAsSeries(IndexBuffer4,true);
   ArraySetAsSeries(IndexBuffer5,true);
   ArraySetAsSeries(IndexBuffer6,true);
   ArraySetAsSeries(IndexBuffer7,true);
   ArraySetAsSeries(Buffer,true);
   ArraySetAsSeries(Buffer1,true);
   ArraySetAsSeries(Buffer2,true);
   ArraySetAsSeries(Buffer3,true);
   ArraySetAsSeries(Buffer4,true);
   ArraySetAsSeries(Buffer5,true);
   ArraySetAsSeries(Buffer6,true);
   ArraySetAsSeries(Buffer7,true);

   IndicatorShortName("Index_RSI_MA");
   SetIndexLabel(0,"AUD");
   SetIndexLabel(1,"CAD");
   SetIndexLabel(2,"CHF");
   SetIndexLabel(3,"EUR");
   SetIndexLabel(4,"GBP");
   SetIndexLabel(5,"JPY");
   SetIndexLabel(6,"NZD");
   SetIndexLabel(7,"USD");   

   ObjectCreate("99",OBJ_HLINE,window,0,99,0,0,0,0);
   ObjectSet("99",OBJPROP_STYLE,STYLE_DOT);
   ObjectSet("99",OBJPROP_COLOR,Yellow);    

   ObjectCreate("97",OBJ_HLINE,window,0,97,0,0,0,0);
   ObjectSet("97",OBJPROP_STYLE,STYLE_DOT);   

   ObjectCreate("3",OBJ_HLINE,window,0,3,0,0,0,0);
   ObjectSet("3",OBJPROP_STYLE,STYLE_DOT);   

   ObjectCreate("1",OBJ_HLINE,window,0,1,0,0,0,0);
   ObjectSet("1",OBJPROP_STYLE,STYLE_DOT);
   ObjectSet("1",OBJPROP_COLOR,Yellow);    
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
  int i;
//---- вычисление минимального кол-ва баров (длины отображаемого графика)
  if(EconomНistori==true)
    {
    BarsMin=100;
    }
  else
  if(EconomНistori==false)
    {
    if(BarsMin==0)
      {
      Barsi[0]=iBars("AUDUSD",0);
      Barsi[1]=iBars("USDCAD",0);
      Barsi[2]=iBars("USDCHF",0);
      Barsi[3]=iBars("EURUSD",0);
      Barsi[4]=iBars("GBPUSD",0);
      Barsi[5]=iBars("USDJPY",0);
      Barsi[6]=iBars("NZDUSD",0);
      }
    BarsMin=Barsi[ArrayMinimum(Barsi)];
    }
// Если появился новый бар, увеличиваем размерность массива и сдвигаем значения на единицу
  if(indBars!=Bars) 
   {
   indBars=Bars;
   ArrayResize(IndexBuffer,BarsMin);ArrayResize(IndexBuffer1,BarsMin);ArrayResize(IndexBuffer2,BarsMin);
   ArrayResize(IndexBuffer3,BarsMin);ArrayResize(IndexBuffer4,BarsMin);ArrayResize(IndexBuffer5,BarsMin);
   ArrayResize(IndexBuffer6,BarsMin);ArrayResize(IndexBuffer7,BarsMin);
   
   ArrayResize(Buffer,BarsMin);ArrayResize(Buffer1,BarsMin);ArrayResize(Buffer2,BarsMin);
   ArrayResize(Buffer3,BarsMin);ArrayResize(Buffer4,BarsMin);ArrayResize(Buffer5,BarsMin);
   ArrayResize(Buffer6,BarsMin);ArrayResize(Buffer7,BarsMin);
       
   for(i=BarsMin-1;i>0;i--)
     {
     IndexBuffer[i]=IndexBuffer[i-1];IndexBuffer1[i]=IndexBuffer1[i-1];IndexBuffer2[i]=IndexBuffer2[i-1];
     IndexBuffer3[i]=IndexBuffer3[i-1];IndexBuffer4[i]=IndexBuffer4[i-1];IndexBuffer2[i]=IndexBuffer5[i-1];
     IndexBuffer3[i]=IndexBuffer6[i-1];IndexBuffer4[i]=IndexBuffer7[i-1];
     
     Buffer[i]=Buffer[i-1];Buffer1[i]=Buffer1[i-1];Buffer2[i]=Buffer2[i-1];Buffer3[i]=Buffer3[i-1];
     Buffer4[i]=Buffer4[i-1];Buffer2[i]=Buffer5[i-1];Buffer3[i]=Buffer6[i-1];Buffer4[i]=Buffer7[i-1];
     }
   IndexBuffer[0]=0.;IndexBuffer1[0]=0.;IndexBuffer2[0]=0.;IndexBuffer3[0]=0.;
   IndexBuffer4[0]=0.;IndexBuffer5[0]=0.;IndexBuffer6[0]=0.;IndexBuffer7[0]=0.;
     
   Buffer[0]=0.;Buffer1[0]=0.;Buffer2[0]=0.;Buffer3[0]=0.;
   Buffer4[0]=0.;Buffer5[0]=0.;Buffer6[0]=0.;Buffer7[0]=0.;
   }
//---- основной цикл
//---- Вычисление индексов
  for(i=BarsMin;i>=0;i--)
    {
    IndexBuffer[i]=AUD(i);
    IndexBuffer1[i]=CAD(i);
    IndexBuffer2[i]=CHF(i);
    IndexBuffer3[i]=EUR(i);
    IndexBuffer4[i]=GBP(i);
    IndexBuffer5[i]=JPY(i);
    IndexBuffer6[i]=NZD(i);
    IndexBuffer7[i]=USD(i);
    }
//---- Вычисление RSI от индексов
  for(i=BarsMin;i>=0;i--)
    {
    Buffer[i]=iRSIOnArray(IndexBuffer,0,PeriodRSI,i);
    Buffer1[i]=iRSIOnArray(IndexBuffer1,0,PeriodRSI,i);
    Buffer2[i]=iRSIOnArray(IndexBuffer2,0,PeriodRSI,i);
    Buffer3[i]=iRSIOnArray(IndexBuffer3,0,PeriodRSI,i);
    Buffer4[i]=iRSIOnArray(IndexBuffer4,0,PeriodRSI,i);
    Buffer5[i]=iRSIOnArray(IndexBuffer5,0,PeriodRSI,i);
    Buffer6[i]=iRSIOnArray(IndexBuffer6,0,PeriodRSI,i);
    Buffer7[i]=iRSIOnArray(IndexBuffer7,0,PeriodRSI,i);
    }
//---- Сглаживание RSI
  for(i=BarsMin;i>=0;i--)
    {
    RSIBuffer[i]=iMAOnArray(Buffer,0,Smooth,0,MODE_EMA,i);
    RSIBuffer1[i]=iMAOnArray(Buffer1,0,Smooth,0,MODE_EMA,i);
    RSIBuffer2[i]=iMAOnArray(Buffer2,0,Smooth,0,MODE_EMA,i);
    RSIBuffer3[i]=iMAOnArray(Buffer3,0,Smooth,0,MODE_EMA,i);
    RSIBuffer4[i]=iMAOnArray(Buffer4,0,Smooth,0,MODE_EMA,i);
    RSIBuffer5[i]=iMAOnArray(Buffer5,0,Smooth,0,MODE_EMA,i);
    RSIBuffer6[i]=iMAOnArray(Buffer6,0,Smooth,0,MODE_EMA,i);
    RSIBuffer7[i]=iMAOnArray(Buffer7,0,Smooth,0,MODE_EMA,i);
    }
//----
  return(0);
  }
//+------------------------------------------------------------------+
double AUD(int j)
  {
  double value;
  datetime TimeBar=Time[j];
  double AUD_USD=iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false));
  double AUD_CAD=iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false))*
                 iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false));
  double AUD_CHF=iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false))*
                 iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false));
  double EUR_AUD=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false))/
                 iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false));
  double GBP_AUD=iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false))/
                 iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false));
  double AUD_JPY=iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false))*
                 iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  double AUD_NZD=iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false))/
                 iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false));
  // Проверка для исключения деления на 0
  if(AUD_USD!=0 && AUD_CAD!=0 && AUD_CHF!=0 && EUR_AUD!=0 && GBP_AUD!=0 && AUD_JPY!=0 && AUD_NZD!=0)
     {
     value = MathPow(AUD_USD*AUD_CAD*AUD_CHF/EUR_AUD/GBP_AUD*AUD_JPY*AUD_NZD,1./8.);
     }
  return(value);
  }
//----
double CAD(int j)
  {
  double value;
  datetime TimeBar=Time[j];
  double AUD_CAD=iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false))*
                 iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false));
  double USD_CAD=iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false));
  double CAD_CHF=1./iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false))*
                 iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false));
  double EUR_CAD=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false))*
                 iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false));
  double GBP_CAD=iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false))*
                 iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false));
  double CAD_JPY=1./iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false))*
                 iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  double NZD_CAD=iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false))*
                 iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false));
  // Проверка для исключения деления на 0
  if(AUD_CAD!=0 && USD_CAD!=0 && CAD_CHF!=0 && EUR_CAD!=0 && GBP_CAD!=0 && CAD_JPY!=0 && NZD_CAD!=0)
     {
     value = MathPow(1./AUD_CAD/USD_CAD*CAD_CHF/EUR_CAD/GBP_CAD*CAD_JPY/NZD_CAD,1./8.);
     }
  return(value);
  } 
//----
double CHF(int j)
  {
  double value;
  datetime TimeBar=Time[j];
  double AUD_CHF=iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false))*
                 iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false));
  double CAD_CHF=1./iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false))*
                 iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false));                 
  double USD_CHF=iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false));  
  double EUR_CHF=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false))*
                 iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false));
  double GBP_CHF=iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false))*
                 iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false));
  double CHF_JPY=1./iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false))*
                 iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  double NZD_CHF=iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false))*
                 iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false));
  // Проверка для исключения деления на 0
  if(AUD_CHF!=0 && CAD_CHF!=0 && USD_CHF!=0 && EUR_CHF!=0 && GBP_CHF!=0 && CHF_JPY!=0 && NZD_CHF!=0)
     {
     value = MathPow(1./AUD_CHF/CAD_CHF/USD_CHF/EUR_CHF/GBP_CHF*CHF_JPY/NZD_CHF,1./8.);
     }
  return(value);
  }
//----
double EUR(int j)
  {
  double value;
  datetime TimeBar=Time[j];
  double EUR_AUD=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false))/
                 iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false));
  double EUR_CAD=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false))*
                 iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false));
  double EUR_CHF=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false))*
                 iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false));  
  double EUR_USD=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false));
  double EUR_GBP=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false))/
                 iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false));
  double EUR_JPY=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false))*
                 iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  double EUR_NZD=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false))/
                 iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false));
  // Проверка для исключения деления на 0
  if(EUR_AUD!=0 && EUR_CAD!=0 && EUR_CHF!=0 && EUR_USD!=0 && EUR_GBP!=0 && EUR_JPY!=0 && EUR_NZD!=0)
     {
     value = MathPow(EUR_AUD*EUR_CAD*EUR_CHF*EUR_USD*EUR_GBP*EUR_JPY*EUR_NZD,1./8.);
     }
  return(value);
  }
//----
double GBP(int j)
  {
  double value;
  datetime TimeBar=Time[j];
  double GBP_AUD=iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false))/
                 iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false));
  double GBP_CAD=iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false))*
                 iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false));
  double GBP_CHF=iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false))*
                 iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false));
  double EUR_GBP=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false))/
                 iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false));
  double GBP_USD=iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false));
  double GBP_JPY=iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false))*
                 iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  double NZD_GBP=iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false))/
                 iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false));
  // Проверка для исключения деления на 0
  if(GBP_AUD!=0 && GBP_CAD!=0 && GBP_CHF!=0 && EUR_GBP!=0 && GBP_USD!=0 && GBP_JPY!=0 && NZD_GBP!=0)
     {
     value = MathPow(GBP_AUD*GBP_CAD*GBP_CHF/EUR_GBP*GBP_USD*GBP_JPY/NZD_GBP,1./8.);
     }
  return(value);
  }
//----
double JPY(int j)
  {
  double value;
  datetime TimeBar=Time[j];
  double AUD_JPY=iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false))*
                 iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  double CAD_JPY=1./iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false))*
                 iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  double CHF_JPY=1./iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false))*
                 iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  double EUR_JPY=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false))*
                 iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  double GBP_JPY=iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false))*
                 iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  double USD_JPY=iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  double NZD_JPY=iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false))*
                 iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  // Проверка для исключения деления на 0
  if(AUD_JPY!=0 && CAD_JPY!=0 && CHF_JPY!=0 && EUR_JPY!=0 && GBP_JPY!=0 && USD_JPY!=0 && NZD_JPY!=0)
     {
     value = MathPow(1./AUD_JPY/CAD_JPY/CHF_JPY/EUR_JPY/GBP_JPY/USD_JPY/NZD_JPY,1./8.);
     }
  return(value);
  }
//----
double NZD(int j)
  {
  double value;
  datetime TimeBar=Time[j];
  double AUD_NZD=iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false))/
                 iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false));
  double NZD_CAD=iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false))*
                 iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false));
  double NZD_CHF=iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false))*
                 iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false));
  double EUR_NZD=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false))/
                 iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false));
  double NZD_GBP=iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false))/
                 iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false));
  double NZD_JPY=iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false))*
                 iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  double NZD_USD=iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false));
  // Проверка для исключения деления на 0
  if(AUD_NZD!=0 && NZD_CAD!=0 && NZD_CHF!=0 && EUR_NZD!=0 && NZD_GBP!=0 && NZD_JPY!=0 && NZD_USD!=0)
     {
     value = MathPow(1./AUD_NZD*NZD_CAD*NZD_CHF/EUR_NZD*NZD_GBP*NZD_JPY*NZD_USD,1./8.);
     }
  return(value);
  }
//----
double USD(int j)
  {
  double value;
  datetime TimeBar=Time[j];
  double AUD_USD=iMA("AUDUSD",0,PeriodEMA,0,1,6,iBarShift("AUDUSD",0,TimeBar,false));
  double USD_CAD=iMA("USDCAD",0,PeriodEMA,0,1,6,iBarShift("USDCAD",0,TimeBar,false));
  double USD_CHF=iMA("USDCHF",0,PeriodEMA,0,1,6,iBarShift("USDCHF",0,TimeBar,false));
  double EUR_USD=iMA("EURUSD",0,PeriodEMA,0,1,6,iBarShift("EURUSD",0,TimeBar,false));
  double GBP_USD=iMA("GBPUSD",0,PeriodEMA,0,1,6,iBarShift("GBPUSD",0,TimeBar,false));
  double USD_JPY=iMA("USDJPY",0,PeriodEMA,0,1,6,iBarShift("USDJPY",0,TimeBar,false));
  double NZD_USD=iMA("NZDUSD",0,PeriodEMA,0,1,6,iBarShift("NZDUSD",0,TimeBar,false));
  // Проверка для исключения деления на 0
  if(AUD_USD!=0 && USD_CAD!=0 && USD_CHF!=0 && EUR_USD!=0 && GBP_USD!=0 && USD_JPY!=0 && NZD_USD!=0)
     {
     value = MathPow(1./AUD_USD*USD_CAD*USD_CHF/EUR_USD/GBP_USD*USD_JPY/NZD_USD,1./8.);
     }
  return(value);
  }

