//+---------------------------------------------------------------------+
//|                                    Copyright © 2008, Robert Hill    |
//+---------------------------------------------------------------------+
#property copyright "Copyright © 2008, Robert Hill"
#property link      ""
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 Lime
#property indicator_color2 Lime
#property indicator_color3 Lime
#property indicator_color4 Lime
#property indicator_color5 Lime
#property indicator_color6 Lime
#property indicator_color7 Lime

extern string Buy_currency_pairs = "----- List of Buy currency pairs -----";
extern string mPair_1 = "GBPUSD";
extern string mPair_2 = "EURGBP";
extern string mPair_3 = "GBPJPY";
extern string mPair_4 = "USDCHF";
extern string mPair_5 = "NZDUSD";
extern string mPair_6 = "AUDJPY";
extern string mPair_7 = "EURJPY";

extern int RSI_Period = 14;
extern int BarsBack = 100;

string Pair1, Pair2, Pair3, Pair4, Pair5, Pair6, Pair7;
double Pair1_Buffer[];
double Pair2_Buffer[];
double Pair3_Buffer[];
double Pair4_Buffer[];
double Pair5_Buffer[];
double Pair6_Buffer[];
double Pair7_Buffer[];

int init()
{
   GetCorrectPairs();
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);
   SetIndexBuffer(0,Pair1_Buffer);
   SetIndexLabel(0,Pair1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID);
   SetIndexBuffer(1,Pair2_Buffer);
   SetIndexLabel(1,Pair2);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID);
   SetIndexBuffer(2,Pair3_Buffer);
   SetIndexLabel(2,Pair3);
   SetIndexStyle(3,DRAW_LINE,STYLE_SOLID);
   SetIndexBuffer(3,Pair4_Buffer);
   SetIndexLabel(3,Pair4);
   SetIndexStyle(4,DRAW_LINE,STYLE_SOLID);
   SetIndexBuffer(4,Pair5_Buffer);
   SetIndexLabel(4,Pair5);
   SetIndexStyle(5,DRAW_LINE,STYLE_SOLID);
   SetIndexBuffer(5,Pair6_Buffer);
   SetIndexLabel(5,Pair6);
   SetIndexStyle(6,DRAW_LINE,STYLE_SOLID);
   SetIndexBuffer(6,Pair7_Buffer);
   SetIndexLabel(6,Pair7);
     
   return(0);
}

int deinit()
{
   return(0);
}

int start()
{
   int i, limit;
   int counted_bars = IndicatorCounted();

   if(counted_bars < 0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars > 0) counted_bars--;

   limit=BarsBack-counted_bars;

   for(i=0; i<limit; i++)
   {
     if (StringLen(Pair1) > 0) Pair1_Buffer[i] = iRSI(Pair1, 0, RSI_Period, PRICE_CLOSE, i); 
     if (StringLen(Pair2) > 0) Pair2_Buffer[i] = iRSI(Pair2, 0, RSI_Period, PRICE_CLOSE, i); 
     if (StringLen(Pair3) > 0) Pair3_Buffer[i] = iRSI(Pair3, 0, RSI_Period, PRICE_CLOSE, i); 
     if (StringLen(Pair1) > 0) Pair4_Buffer[i] = iRSI(Pair4, 0, RSI_Period, PRICE_CLOSE, i); 
     if (StringLen(Pair5) > 0) Pair5_Buffer[i] = iRSI(Pair5, 0, RSI_Period, PRICE_CLOSE, i); 
     if (StringLen(Pair6) > 0) Pair6_Buffer[i] = iRSI(Pair6, 0, RSI_Period, PRICE_CLOSE, i); 
     if (StringLen(Pair7) > 0) Pair7_Buffer[i] = iRSI(Pair7, 0, RSI_Period, PRICE_CLOSE, i); 
   }
return(0);
}

void GetCorrectPairs()
{
   Pair1 = GetCorrectSymbol(mPair_1);
   Pair2 = GetCorrectSymbol(mPair_2);
   Pair3 = GetCorrectSymbol(mPair_3);
   Pair4 = GetCorrectSymbol(mPair_4);
   Pair5 = GetCorrectSymbol(mPair_5);
   Pair6 = GetCorrectSymbol(mPair_6);
   Pair7 = GetCorrectSymbol(mPair_7);
   
}

string GetCorrectSymbol(string pair)
{
   string AddChar, myPair;
   
   myPair = pair;
   if (StringLen(Symbol()) == 7)
   {
      AddChar = StringSubstr(Symbol(), 6, 1);
      myPair = pair + AddChar;
   }
   return(myPair);
   
}

