Moving Average Crossovers - MAcrosses

Technical Forex Market Indikátor pre Metatrader

Technical Forex Market Indikátor pre Metatrader
MAcrosses
Technical Forex Market Indikátor pre Metatrader
MAcrosses
Technical Forex Market Indikátor pre Metatrader
MAcrosses
Technical Forex Market Indikátor pre Metatrader
MAcrosses





MA Crossover is a very interesting technical indicator, where forms the basis Moving average. Moving average - MA simply measure the average price or exchange rate of a currency pair over a specific time frame. An indicator frequently used in technical analysis showing the average value of a security's price over a set period. See more on indicators  Moving average - MA. MA Crossover is strongly limited levels of 0 to 100, allowing the trader to better see the bottom and  peak of the market. By passing a zero-Lines (10 or 90) points to buy or sell. For better business results should be combined with indicator Bollinger Bands, Commodity Channel Index - CCI etc., or with trend indicator, for example Moving average.


Moving Average Crossovers - MAcrosses MQ4 Code Base (Copy Code)
//+-------------------------------------------------------------------------------------------+
//|                                                                              MAcrosses.mq4|
//|                                      Copyright © 2011, Matus German, matusgerman@gmail.com|
//|                                                                                           |
//| Counts crosses off MAs, it shows % that all MAs are above slower MAs                      |
//| If an MA crosses above another, the indicator rises                                       |
//| If an MA crosses under another, the indicator falls                                       |
//| If the indicator rises to 100%, every MA is above MAs with higher period                  |
//| If the indicator falls to 0%, every MA is under MAs with higher period                    |                                   
//+-------------------------------------------------------------------------------------------+
#property copyright "Matus German"
#property link      ""

#property indicator_separate_window
#property indicator_buffers 2               // Number of buffers
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_color1 Red
#property indicator_color2 Blue

double MAcrs[];
double MAcrsAvg[];
extern int MA = 50;                    // the maximal MA
extern int MAavg = 20;                // parameter to calculate moving average from MAcrosses
extern int MAmethod = 1;               // iMA moving average method: 
                                       //          0 Simple moving average,
                                       //          1 Exponential moving average,
                                       //          2 Smoothed moving average,
                                       //          3 Linear weighted moving average.

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

//---- indicators
    IndicatorBuffers(2);
    SetIndexBuffer(0,MAcrs);
    SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);
    SetIndexBuffer(1,MAcrsAvg);
    SetIndexStyle (1,DRAW_LINE,STYLE_DASH,1);
//----
   SetLevelValue(0,10);
   SetLevelValue(1,90);
   return;
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

// Function counts how many crosses could be made by MAs
int max(int MA,int MAstep)
{  
   int max=0;
   int MAcount=MA/MAstep;
   while(MAcount>0)
   {  
      MAcount=MAcount-1;
      max=max+MAcount;
   }
   return (max);
}

////////////////////////////////////////////////////////////////////
int start()
{
   double MAstep = (MA * 0.1);               // diference between MAs
   int    counted_bars,i,j,k;
   double crosses;

   if(Bars<=MA) return(0);
   
   counted_bars=IndicatorCounted();          // Number of counted bars
   i=Bars-counted_bars-1;                    // Index of the first uncounted
   
   while(i>=0)
   {  
      crosses=0;                   
      k=MA;
      while(k>0)
      {  
         j=MA;
         while(j>k)
         {  

            if(iMA(NULL,0,j,0,MAmethod,PRICE_MEDIAN,i)<iMA(NULL,0,k,0,MAmethod,PRICE_MEDIAN,i))
            {
               crosses=crosses+1;                          // count crosses
            }
            j=j-MAstep;
         }
         k=k-MAstep;
      }
      MAcrs[i]=(crosses/max(MA,MAstep))*100;      // % that all MAs are abowe slower MAs
      
      double MAcrsSum=0;
      int l;
      for(l=i; l<i+MAavg;l++)
      {
         MAcrsSum = MAcrsSum + MAcrs[l];
      }
      
      MAcrsAvg[i]=MAcrsSum/MAavg;                 // MAcrosses average
      
      i--;
   }
   return;
}
//+------------------------------------------------------------------+