MAAngle Indicator

 

Greetings everyone,

Ive been doing some research on the Moving Average Indicator a.k.a (MAAngle Indicator) and i came across this site that has the coding/programming for the indicator.

Ive heard from several other successful trading systems that the MAAngle indicator is 80% of the time precise in determining the trend of markets on different TF's and comparing them...Is anyone here able to program this into a working indicator ..

Thanks

Here is the code exactly as it is on the website:

--------------------------------------------------------------------------

//+------------------------------------------------------------------+

//| MAAngle.mq4 |

//| original jpkfox |

//| edited by dariuske |

//| You can use this indicator to measure when the MA angle is |

//| "near zero". AngleTreshold determines when the angle for the |

//| EMA is "about zero": This is when the value is between |

//| [-AngleTreshold, AngleTreshold] (or when the histogram is red). |

//| MAMode : 0 = SMA, 1 = EMA, 2 = Smoothed, 3 = Weighted |

//| MAPeriod: MA period |

//| AngleTreshold: The angle value is "about zero" when it is |

//| between the values [-AngleTreshold, AngleTreshold]. |

//| StartMAShift: The starting point to calculate the |

//| angle. This is a shift value to the left from the |

//| observation point. Should be StartEMAShift > EndEMAShift. |

//| StartMAShift: The ending point to calculate the |

//| angle. This is a shift value to the left from the |

//| observation point. Should be StartEMAShift > EndEMAShift. |

//| |

//| Modified by MrPip |

//| Red for down |

//| Yellow for near zero |

//| Green for up |

//| 10/15/05 MrPip |

//| Corrected problem with USDJPY and optimized code |

//| 10/23/05 Added other JPY crosses |

//| |

//| |

//| |

//| 12/01/07 Dariuske: Changed code for SMA50 (PhilNelSystem) |

//| 18/01/07 Dariuske: Changed code for multiple mode MA's |

//+------------------------------------------------------------------+

#property copyright "jpkfox"

#property link "http://www.strategybuilderfx.com/forums/showthread.php?t=15274&page=1&pp=8"

//---- indicator settings

#property indicator_separate_window

#property indicator_buffers 3

#property indicator_color1 LimeGreen

#property indicator_color2 FireBrick

#property indicator_color3 Yellow

//---- indicator parameters

extern int MAMode = 0;

extern int MAPeriod=50;

extern int Price=4;

extern double AngleTreshold=0.25;

extern int StartMAShift=2;

extern int EndMAShift=0;

//---- indicator buffers

double UpBuffer[];

double DownBuffer[];

double ZeroBuffer[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- 2 additional buffers are used for counting.

IndicatorBuffers(3);

//---- drawing settings

SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,4);

SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,4);

SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,4);

IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);

//---- 3 indicator buffers mapping

if(!SetIndexBuffer(0,UpBuffer) &&

!SetIndexBuffer(1,DownBuffer) &&

!SetIndexBuffer(2,ZeroBuffer))

Print("cannot set indicator buffers!");

//---- name for DataWindow and indicator subwindow label

//IndicatorShortName("MAAngle("+MAPeriod+","+AngleTreshold+","+StartMAShift+","+EndMAShift+")");

IndicatorShortName("MAAngle");

//---- initialization done

return(0);

}

//+------------------------------------------------------------------+

//| The angle for EMA |

//+------------------------------------------------------------------+

int start()

{

double fEndMA, fStartMA;

double fAngle, mFactor, dFactor;

int nLimit, i;

int nCountedBars;

double angle;

int ShiftDif;

string Sym;

if (MAMode >= 4) MAMode = 0;

if(EndMAShift >= StartMAShift)

{

Print("Error: EndMAShift >= StartMAShift");

StartMAShift = 6;

EndMAShift = 0;

}

nCountedBars = IndicatorCounted();

//---- check for possible errors

if(nCountedBars<0)

return(-1);

//---- last counted bar will be recounted

if(nCountedBars>0)

nCountedBars--;

nLimit = Bars-nCountedBars;

dFactor = 2*3.14159/180.0;

mFactor = 10000.0;

Sym = StringSubstr(Symbol(),3,3);

if (Sym == "JPY") mFactor = 100.0;

ShiftDif = StartMAShift-EndMAShift;

mFactor /= ShiftDif;

//---- main loop

for(i=0; i<nLimit; i++)

{

fEndMA=iMA(NULL,0,MAPeriod,0,MAMode,Price,i+EndMAShift);

fStartMA=iMA(NULL,0,MAPeriod,0,MAMode,Price,i+StartMAShift);

// 10000.0 : Multiply by 10000 so that the fAngle is not too small

// for the indicator Window.

fAngle = mFactor * (fEndMA - fStartMA)/2.0;

//fAngle = MathArctan(fAngle)/dFactor;

DownBuffer = 0.0;

UpBuffer = 0.0;

ZeroBuffer = 0.0;

if(fAngle > AngleTreshold)

UpBuffer = fAngle;

else if (fAngle < -AngleTreshold)

DownBuffer = fAngle;

else ZeroBuffer = fAngle;

}

return(0);

}

//+------------------------------------------------------------------+

Here is the link to the site directly if that helps...

MAAngle.mq4

Thanks a lot

Fxrulez

 

MA Angle

Greetings everyone,

Ive been doing some research on the Moving Average Indicator a.k.a (MAAngle Indicator) and i came across this site that has the coding/programming for the indicator.

Ive heard from several other successful trading systems that the MAAngle indicator is 80% of the time precise in determining the trend of markets on different TF's and comparing them...Is anyone here able to program this into a working indicator ..

Thanks

All the code was there it just had a couple of gaps that should not have been in the code which prevented it compiling, i have altered the Bar width code so that it can be user adjusted without going into the source.

I just had another look at the MA Angle indicator and added a MTF code to it, i think it is working alright however get back to me if you have any problems.

ma_angle.mq4

ma_angle_mtf.mq4

Files:
 

cja

That was really fast. Thanks a lot for that...Will test it out now...

Cheers

 

Thank you very much cja, as always, you are the man

ServerUang

 

Props to cja and fxrulez, this indicator is great! Does a great job of simplifying the measurement of the angle to filter bad signals, a jewel for MA cross strategies.

 

Nice work ....

 

what are bad signals

the illustration does not make it easier for us to see

 

??????

xx3xxx:
what are bad signals the illustration does not make it easier for us to see

Don't you mean

the illustration does not make it easier for ME to see

Have you considered what the Yellow areas mean???

Have you tried adjusting the inputs to see how it works???

 

Looks promising, thanks CJA.

Files:
ma_angle.gif  80 kb
 
xx3xxx:
what are bad signals the illustration does not make it easier for us to see

Everything depends on the settings - the MA, the time period you're using and the threshold you have set, along with your own vision.

In MA cross strategies, bad signals are crosses when MAs have a very small angle, which indicates a non-trending market.

Here's a quick example...

Files:
maangle.jpg  253 kb
 

???

Is there a way to rewrite MA angle indicator so it will show only positive values???...and show color only when it reaches a certain angle (like in stochastics color oversold/overbought)...