//+------------------------------------------------------------------+
//|                                                  MA_strength.mq4 |
//|                                                        Taiyakixz |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Taiyakixz"
#property link      ""

#property indicator_separate_window

#property indicator_color1 DodgerBlue
#property indicator_level1 0
extern int MA_Period = 14;
extern int MA_Method = 1;
extern int Strength_Period = 1;

double MAStrengthBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(1);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);
   SetIndexBuffer(0,MAStrengthBuffer);
   start();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double ma0, ma1, difMa;
   int counted_bars=IndicatorCounted();
   int i, limit;

   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//----
   for( i = limit; i >=0; i-- )
   {
     ma0 = iMA(Symbol(), 0, MA_Period, 0, MA_Method, PRICE_CLOSE, i);
     ma1 = iMA(Symbol(), 0, MA_Period, 0, MA_Method, PRICE_CLOSE, i+Strength_Period);
     MAStrengthBuffer[i] = ma0 - ma1;
   }
//----

   return(0);
  }
//+------------------------------------------------------------------+