//+------------------------------------------------------------------+
//|                                                      ROC_EUR.mq4 |
//|                                                 Kris Tokarzewski |
//|                                  based on work done by Davi Chan |
//+------------------------------------------------------------------+
#property copyright " © Kris "

#property indicator_buffers 1
#property indicator_separate_window
#property indicator_color1 Lime

extern int periodos = 10;
double medidor_operacoes = 0;
double buffer_indicador[];
int i;

//extern int maxbars = 0; //maxbars limita quando não estiver no modo teste.
int maxbars;

int init()
{
// if(IsTesting())
//   maxbars = Bars;
//	else
//	  maxbars = 500;
	SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
	SetIndexBuffer(0, buffer_indicador);
	SetLevelValue(0,0.0);
	return(0);
   }

int start()
   {
	int inicio;   	
	double roc_USD, roc_GBP, roc_JPY, roc;
	int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   for(int i=0; i<limit; i++)
      {
		roc = 0;			
      roc_USD = (iClose("EURUSD", 0, i) - iClose("EURUSD", 0, periodos+i))/iClose("EURUSD", 0, periodos+i);
      roc_GBP = (iClose("EURGBP", 0, i) - iClose("EURGBP", 0, periodos+i))/iClose("EURGBP", 0, periodos+i);
      roc_JPY = (iClose("EURJPY", 0, i) - iClose("EURJPY", 0, periodos+i))/iClose("EURJPY", 0, periodos+i);
      //inversão dos valores dessas duas moedas
//    roc_JPY = (1/iClose("EURJPY", 0, i) - 1/iClose("EURJPY", 0, periodos+i))/(1/iClose("EURJPY", 0, periodos+i));
      //inversão dos valores dessas duas moedas
      roc = (roc_USD + roc_GBP + roc_JPY)/3;
		buffer_indicador[i] = roc;			
	  }
}

