//+------------------------------------------------------------------+
//|                                                         Devs.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 DeepSkyBlue
#property indicator_color3 MediumSpringGreen
#property indicator_color4 Yellow
//---- input parameters
extern int       period=15;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ExtMapBuffer4);
//----
   SetIndexLabel(0,"m1");
   SetIndexLabel(1,"m5");
   SetIndexLabel(2,"m15");
   SetIndexLabel(3,"m30");

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();

   int i=Bars-counted_bars-1;
   
   while(i>=0){
        ExtMapBuffer1[i] = (iMA(Symbol(), 1, period, 0,MODE_EMA,PRICE_CLOSE,i) - Close[i]) / Close[i];
        ExtMapBuffer2[i] = (iMA(Symbol(), 5, period, 0,MODE_EMA,PRICE_CLOSE,i) - Close[i]) / Close[i];
        ExtMapBuffer3[i] = (iMA(Symbol(), 15, period, 0,MODE_EMA,PRICE_CLOSE,i) - Close[i]) / Close[i];
        ExtMapBuffer4[i] = (iMA(Symbol(), 30, period, 0,MODE_EMA,PRICE_CLOSE,i) - Close[i]) / Close[i];
        i--;   
    }
   return(0);
  }
//+------------------------------------------------------------------+