MA without consolidation problem

0
(0)
Name:
MA without consolidation problem
Author: forexavatar (2010.02.24 11:22)
Downloaded: 10828
Download:
MA without consolidation problem 1
 MaStillWorks.mq4 (2.2 Kb) View
 

Description:

The big problem of all MA indicators is giving false signals in consolidation moments. This indicator uses simple trick to eliminate false signals in consolidation.

Image:

MA without consolidation problem 2

 

How to identify consolidation?

Get max and min values from a few last candles - if current price contains in max and min area ( min > PRICE < max ) we can say that it's a consolidation moment.

   int candles = 6; 
   double min = Low[iLowest(NULL,0,MODE_LOW,candles,i+2)];
   double max = High[iHighest(NULL,0,MODE_HIGH,candles,i+2)];

   bool horizontal = false;
   if(ma[0] < max && ma[0] > min)
   {
      horizontal = true;
   }

Signal function where i - number of bar

int MovingAverage(int i)
{
   double ma[3];
   int period = _Period;
   ma[0] = iMA(NULL,0,period,0,MODE_EMA,PRICE_MEDIAN,i);
   ma[1] = iMA(NULL,0,period,0,MODE_EMA,PRICE_MEDIAN,i+1);
   ma[2] = iMA(NULL,0,period,0,MODE_EMA,PRICE_MEDIAN,i+2);

   int candles = 6; 
   double min = Low[iLowest(NULL,0,MODE_LOW,candles,i+2)];
   double max = High[iHighest(NULL,0,MODE_HIGH,candles,i+2)];

   bool horizontal = false;
   if(ma[0] < max && ma[0] > min)
   {
      horizontal = true;
   }

   if(ma[1] < ma[0] && horizontal == false)
   {
      return(1);
      Print(" ");
   }
   else if(ma[1] > ma[0] && horizontal == false)
   {
      return(-1);
   }
   else
   {
      return(0);
   }
}

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?



Author: Forex Wiki Team
We are a team of highly experienced Forex Traders [2000-2023] who are dedicated to living life on our own terms. Our primary objective is to attain financial independence and freedom, and we have pursued self-education and gained extensive experience in the Forex market as our means to achieve a self-sustainable lifestyle.