//+------------------------------------------------------------------+
//|                                                         кукл.mq4 |
//|                                                         Pegaskrs |
//|                                    http://forum.tradelikeapro.ru |
//+------------------------------------------------------------------+

/*Корзина USD
 USDCAD, USDCHF, USDJPY

 EURUSD, GBPUSD, AUDUSD, NZDUSD
*/
#property copyright "Pegaskrs"
#property link      "http://forum.tradelikeapro.ru"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_minimum    0
#property indicator_maximum    100
#property indicator_buffers    1
#property indicator_color1     DodgerBlue
#property indicator_level1     30.0
#property indicator_level2     70.0
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT


input int timeframe     =  0;
input int period        = 14;    // период
input int applied_price =  0;    // тип цены
input int CountBars     = 400;
double ExtRSIBuffer[];
string ExtBufferPair[] = { "EURUSD", "GBPUSD", "AUDUSD", "NZDUSD","USDCAD", "USDCHF", "USDJPY"};
int OnInit()
  {     string short_name = "Кукл USD/RSI";
        SetIndexStyle(0,DRAW_LINE);
        SetIndexBuffer(0, ExtRSIBuffer);
        SetIndexDrawBegin(0,Bars -CountBars );
        IndicatorShortName(short_name);
   return(INIT_SUCCEEDED);
  }

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   int i,r,limit;
   double Rsi;
   limit = MathMin(rates_total-prev_calculated,CountBars);
   for ( i=limit; i>=0; i--){
       Rsi =0;
       for ( r =ArraySize(ExtBufferPair)-1; r>=0; r--){
           Rsi += iRSI(ExtBufferPair[r],timeframe,period,applied_price,i);}
           ExtRSIBuffer[i]= Rsi/ ArraySize(ExtBufferPair);      
       }
   return(rates_total);
  }
//+------------------------------------------------------------------+
