
 
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Black
#property indicator_color4 Orange

#property indicator_level1 0

//----

extern int Fast = 25;
extern int Slow = 50;



extern color index_a = Lime;
extern color index_b = Red;
extern color index_c = Black;
extern color index_d = Orange;

extern int epaisseur= 1;

extern int CountBars = 1000;
//---- buffers
double Paire_1[];
double Paire_2[];
double Paire_3[];
double Paire_4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0, DRAW_LINE,0,epaisseur,index_a);
   SetIndexBuffer(0, Paire_1);
   SetIndexStyle(1, DRAW_LINE,0,epaisseur,index_b);
   SetIndexBuffer(1, Paire_2);
   SetIndexStyle(2, DRAW_LINE,0,epaisseur,index_c);
   SetIndexBuffer(2, Paire_3);
     SetIndexStyle(3, DRAW_LINE,0,epaisseur,index_d);
   SetIndexBuffer(3, Paire_4);
//---- name for DataWindow and indicator subwindow label
   short_name = "MACD Index";
   IndicatorShortName(short_name);
   SetIndexLabel(0, short_name);
//----
   if(CountBars >= Bars) 
   CountBars = Bars;
   SetIndexDrawBegin(0, Bars - CountBars + 10 + 1);
//----
   return(0);
  }

int start()
  {
   int i, counted_bars=IndicatorCounted();
 int TotalWindow=WindowsTotal();

  if (ObjectFind("EUR")<0)
     {
     ObjectCreate("EUR",OBJ_LABEL,TotalWindow-1,0,0);
     ObjectSet("EUR",OBJPROP_XDISTANCE,500);
     ObjectSet("EUR",OBJPROP_YDISTANCE,1);
     ObjectSetText("EUR","EUR",12,"Arial",index_a);
     }
  if (ObjectFind("GBP")<0)
     {
     ObjectCreate("GBP",OBJ_LABEL,TotalWindow-1,0,0);
     ObjectSet("GBP",OBJPROP_XDISTANCE,600);
     ObjectSet("GBP",OBJPROP_YDISTANCE,1);
     ObjectSetText("GBP","GBP",12,"Arial",index_b);
     }
  if (ObjectFind("USD")<0)
     {
     ObjectCreate("USD",OBJ_LABEL,TotalWindow-1,0,0);
     ObjectSet("USD",OBJPROP_XDISTANCE,700);
     ObjectSet("USD",OBJPROP_YDISTANCE,1);
     ObjectSetText("USD","USD",12,"Arial",index_c);
     }
  if (ObjectFind("JPY")<0)
     {
     ObjectCreate("JPY",OBJ_LABEL,TotalWindow-1,0,0);
     ObjectSet("JPY",OBJPROP_XDISTANCE,800);
     ObjectSet("JPY",OBJPROP_YDISTANCE,1);
     ObjectSetText("JPY","JPY",12,"Arial",index_d);
     }
     

  
//----
   if(Bars <= 10) 
       return(0);
//---- initial zero
   if(counted_bars < 10)
     {
       for(i = 1; i <= 10; i++) 
           Paire_1[CountBars-i] = 0.0;
     }
//----
   i = CountBars - 10 - 1;
   
//----
   while(i >= 0)
     {
       Paire_1[i]=(iMACD("EURUSD",0,Fast,Slow,9,PRICE_CLOSE,MODE_MAIN,i)/iATR("EURUSD",0,20,i))+(iMACD("EURGBP",0,Fast,Slow,9,PRICE_CLOSE,MODE_MAIN,i)/iATR("EURGBP",0,20,i))+(iMACD("EURJPY",0,Fast,Slow,9,PRICE_CLOSE,MODE_MAIN,i)/iATR("EURJPY",0,20,i));
       Paire_2[i]=(iMACD("GBPUSD",0,Fast,Slow,9,PRICE_CLOSE,MODE_MAIN,i)/iATR("GBPUSD",0,20,i))+(iMACD("GBPJPY",0,Fast,Slow,9,PRICE_CLOSE,MODE_MAIN,i)/iATR("GBPJPY",0,20,i))+(-iMACD("EURGBP",0,Fast,Slow,9,PRICE_CLOSE,MODE_MAIN,i)/iATR("EURGBP",0,20,i));
       Paire_3[i]=(-iMACD("GBPUSD",0,Fast,Slow,9,PRICE_CLOSE,MODE_MAIN,i)/iATR("GBPUSD",0,20,i))+(iMACD("USDJPY",0,Fast,Slow,9,PRICE_CLOSE,MODE_MAIN,i)/iATR("USDJPY",0,20,i))+(-iMACD("EURUSD",0,Fast,Slow,9,PRICE_CLOSE,MODE_MAIN,i)/iATR("EURUSD",0,20,i));
       Paire_4[i]=(-iMACD("GBPJPY",0,Fast,Slow,9,PRICE_CLOSE,MODE_MAIN,i)/iATR("GBPJPY",0,20,i))+(-iMACD("USDJPY",0,Fast,Slow,9,PRICE_CLOSE,MODE_MAIN,i)/iATR("USDJPY",0,20,i))+(-iMACD("EURJPY",0,Fast,Slow,9,PRICE_CLOSE,MODE_MAIN,i)/iATR("EURJPY",0,20,i));

       i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+