//+------------------------------------------------------------------+
//|                                                  RatioMA_RSI.mq4 |
//|                                                        fabgonber |
//|                                             http://www.ignora.cl |
//+------------------------------------------------------------------+
#property copyright "fabgonber"
#property link      "http://www.ignora.cl"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 White
#property indicator_color4 Yellow

// parametros
extern int periodos_rsi = 14;
extern int periodos_media_lenta = 30;
extern int periodos_media_rapida = 10;

//---- buffers
   double rsi[];
   double rsima10[];
   double rsima30[];
   double fuerza[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE, STYLE_DOT, 1);
   SetIndexBuffer(0,rsima10);

   SetIndexStyle(1,DRAW_LINE, STYLE_DOT, 1);
   SetIndexBuffer(1,rsima30);

   SetIndexStyle(2,DRAW_LINE, STYLE_DOT, 1);
   SetIndexBuffer(2,rsi);

   SetIndexStyle(3,DRAW_LINE, STYLE_DOT, 1);
   SetIndexBuffer(3,fuerza);

   start();
   

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int i;
   int Barras = 300;

//----
   for (i=0;i<Barras;i++){
      rsi[i] = iRSI(NULL,PERIOD_D1,periodos_rsi,PRICE_CLOSE,i);
   }
   for (i=0;i<Barras;i++){
      rsima10[i] = iMAOnArray(rsi,0,periodos_media_rapida,0,MODE_SMA,i);
   }
   for (i=0;i<Barras;i++){
      rsima30[i] = iMAOnArray(rsi,0,periodos_media_lenta,0,MODE_SMA,i);
   }
   
   for (i=0;i<Barras;i++){
   if (rsima30[i] != 0)
      fuerza[i] = (rsima10[i]/rsima30[i])*100;
   }

//----
   return(0);
  }
//+------------------------------------------------------------------+