//+------------------------------------------------------------------+
//|                                                    supreme c.mq4 |
//|                                                          ......h |
//|                                                    hayseedfx.com |
//+------------------------------------------------------------------+
#property copyright "......h"
#property link      "hayseedfx.com"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red

//---- input parameters
extern int       periods   =   50;

extern string    plot      = "0==Macd, 1==AbsV";
extern int       choice    =    0;


//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  
   int    counted_bars=IndicatorCounted();
   int    limit;
   int i;
//----
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- 
   if(choice == 0)
   {
   for(i=0; i<limit; i++)
      ExtMapBuffer1[i]=(Close[i]-iMA(NULL,0,periods,0,1,0,i+1))/Point;   
   }
   
   
   if(choice == 1)
   {
   for(i=0; i<limit; i++)
      ExtMapBuffer1[i]=MathAbs((Close[i]-iMA(NULL,0,periods,0,1,0,i+1))/Point);   
   }   
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+