Navigation:Home > Content >

ma_crosses.mq4

Time: 2011-12-09 | Download file:ma_crosses.mq4

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#property copyright "www.forex-tsd.com"
#property link      "www.forex-tsd.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1  Blue
#property indicator_color2  Red

//
//
//
//
//

extern int FasterMA = 4;
extern int SlowerMA = 5;
extern int MAMode   = MODE_EMA;
extern int MAPrice  = PRICE_CLOSE;

//
//
//
//
//

double CrossUp[];
double CrossDown[];
double State[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
   IndicatorBuffers(3);
   SetIndexBuffer(0, CrossUp);   SetIndexStyle(0, DRAW_ARROW); SetIndexArrow(0, 233);
   SetIndexBuffer(1, CrossDown); SetIndexStyle(1, DRAW_ARROW); SetIndexArrow(1, 234);
   SetIndexBuffer(2, State);
   return(0);
}
int deinit() { return(0); }

//
//
//
//
//

int start() {
   int counted_bars=IndicatorCounted();
   int i,limit;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
         limit = MathMin(Bars-counted_bars,Bars-1);

   //
   //
   //
   //
   //
   
   for(i=limit; i>=0; i--)
   {
      double range  = iATR(NULL,0,10,i);
      double maFast = iMA(NULL,0,FasterMA,0,MAMode,MAPrice,i);
      double maSlow = iMA(NULL,0,SlowerMA,0,MAMode,MAPrice,i);

         CrossUp[i]   = EMPTY_VALUE;
         CrossDown[i] = EMPTY_VALUE;
         State[i]     = State[i+1];
            if (maFast>maSlow) State[i] =  1;
            if (maFast        

Recommend