- June 24, 2013
- Posted by: Forex Wiki Team
- Category: FX Ind
No Comments
1606
1478
Contents
Name: |
|
||
Author: | forexavatar (2010.02.24 11:22) | ||
Downloaded: | 10828 | ||
Download: |
|
||
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:
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); } } |