
//+------------------------------------------------------------------+
//|                                               mn 2 Pair Spread   |
//+------------------------------------------------------------------+

#property  copyright "Mn"
#property  link      ""
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue  
#property indicator_color2 Red  

extern string mPair2 = "EURGBP";
extern int mPrd = 10, mPrd2 = 50;
string mPair1 ;
double PairSpread[], PairSpread2[];

//+------------------------------------------------------------------+
int init()
{
   SetIndexBuffer(0, PairSpread);
   SetIndexStyle(0,DRAW_LINE, 0, 2, Blue); 
   SetIndexLabel(0, NULL);
   SetIndexBuffer(1, PairSpread2);
   SetIndexStyle(1,DRAW_LINE, 0, 2, Red); 
   SetIndexLabel(1, NULL);
   
   mPair1 = Symbol();
   return (0);
}

//+------------------------------------------------------------------+
int deinit()
{
   return (0);
}

//+------------------------------------------------------------------+
int start()
{
   double mP1 = 0.0, mP2 = 0.0, mP12 = 0.0, mP22 = 0.0;
   int counted_bars = IndicatorCounted();
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars--;
   int limit = Bars - counted_bars;

   for (int i = limit; i >= 0; i--)
   {
     mP1 = iMA(mPair1, 0, mPrd, 0, 0, PRICE_CLOSE, i);
     mP2 = iMA(mPair2, 0, mPrd, 0, 0, PRICE_CLOSE, i); 
     mP12 = iMA(mPair1, 0, mPrd2, 0, 0, PRICE_CLOSE, i);
     mP22 = iMA(mPair2, 0, mPrd2, 0, 0, PRICE_CLOSE, i); 

     PairSpread[i] = mP1 - mP2;
     PairSpread2[i] = mP12 - mP22;

   }

   return(0);
}

//+------------------------------------------------------------------+

