MasTrend





//+------------------------------------------------------------------+
//|                                                     MasTrend.mq4 |
//|                                                           mladen |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "mladenfx@gmail.com"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_color2 DimGray
#property indicator_width1 1

//
//
//
//
//

extern int   Price         = PRICE_CLOSE;
extern int   Mas.Type      = MODE_SMA;
extern int   Mas.Start     = 20;
extern int   Mas.End       = 200;
extern int   Mas.Step      = 10;


//
//
//
//
//

double MasTrendBuffer[];

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

int init()
{
   SetIndexBuffer(0,MasTrendBuffer);
   return(0);
}

//
//
//
//
//

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


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

   //
   //
   //
   //
   //

   for(i=limit; i>=0; i--)
   {
      double price     = iMA(NULL,0,1,0,MODE_SMA,Price,i);
      int    masPeriod = Mas.Start;
      int    masCount  = 0;
      int    total     = 0;
      
      for (; masPeriod<=Mas.End; masPeriod+= Mas.Step, masCount++)
      {
         double ma = iMA(NULL,0,masPeriod,0,Mas.Type,Price,i);
            if (price > ma) total++;
            if (price < ma) total--;             
      }
      MasTrendBuffer[i] = 100.00*total/masCount;            
   }   
   return(0);
}



Sample





Analysis



Market Information Used:



Indicator Curves created:



Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: