//+------------------------------------------------------------------+
//|                                              PhilipNelsMaSet.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Jim Hodges Software Corp."
#property link      "http://www.robotmaster.com/"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Black
#property indicator_color2 Blue
#property indicator_color3 Magenta
#property indicator_color4 Yellow

//---- input parameters
extern int SuperSlowMa=200;
extern int SuperSlowMaShift=0;
extern int SuperSlowMaMethod=0;
extern int SuperSlowMaAppliedTo=0;

extern int SlowMa=89;
extern int SlowMaShift=0;
extern int SlowMaMethod=0;
extern int SlowMaAppliedTo=0;

extern int MediumMa=21;
extern int MediumMaShift=0;
extern int MediumMaMethod=1;
extern int MediumMaAppliedTo=0;

extern int FastMa=8;
extern int FastMaShift=0;
extern int FastMaMethod=1;
extern int FastMaAppliedTo=0;
//---- indicator buffers
double ExtGreenBuffer[];
double ExtBlueBuffer[];
double ExtRedBuffer[];
double ExtLimeBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- line shifts when drawing
   SetIndexShift(0,SuperSlowMaShift);
   SetIndexShift(1,SlowMaShift);
   SetIndexShift(2,MediumMaShift);
   SetIndexShift(3,FastMaShift);
//---- first positions skipped when drawing
   SetIndexDrawBegin(0,SuperSlowMaShift+SuperSlowMa);
   SetIndexDrawBegin(1,SlowMaShift+SlowMa);
   SetIndexDrawBegin(2,MediumMaShift+MediumMa);
   SetIndexDrawBegin(3,FastMaShift+FastMa);
//---- 3 indicator buffers mapping
   SetIndexBuffer(0,ExtGreenBuffer);
   SetIndexBuffer(1,ExtBlueBuffer);
   SetIndexBuffer(2,ExtRedBuffer);
   SetIndexBuffer(3,ExtLimeBuffer);
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE,EMPTY,2);
   SetIndexStyle(1,DRAW_LINE,EMPTY,2);
   SetIndexStyle(2,DRAW_LINE,EMPTY,2);
   SetIndexStyle(3,DRAW_LINE,EMPTY,2);
//---- index labels
   SetIndexLabel(0,"SuperSlowMa");
   SetIndexLabel(1,"SlowMa");
   SetIndexLabel(2,"MediumMa");
   SetIndexLabel(3,"FastMa");
//---- initialization done
   return(0);
  }

int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(int i=0; i<limit; i++)
     {
      ExtGreenBuffer[i]=iMA(NULL,0,SuperSlowMa,0,SuperSlowMaMethod,SuperSlowMaAppliedTo,i);
      ExtBlueBuffer[i]=iMA(NULL,0,SlowMa,0,SlowMaMethod,SlowMaAppliedTo,i);
      ExtRedBuffer[i]=iMA(NULL,0,MediumMa,0,MediumMaMethod,MediumMaAppliedTo,i);
      ExtLimeBuffer[i]=iMA(NULL,0,FastMa,0,FastMaMethod,FastMaAppliedTo,i);
     }
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

