MA Angle Indicator

Avatar
  • updated

Hello,

I have created this indicator that shows on each candle the value of the "Angle" of the MA as used in CommunityPower

https://communitypowerea.com/docs/signals-and-filters#ma-filters


Doc:

  • Buy on rising MA / Sell on falling MA:
    • BUYs are allowed if the MA rises with a slope >= Angle
    • SELLs are allowed if the MA falls with a slope >= Angle

Slope is calculated as (MA[1] - MA[2]), meaning that the MA should change by Angle points per bar to generate a signal

Image 6196

MT5:

MA_Angle.ex5
MA_Angle.mq5

Any improvements to the code, please share.

Avatar

Thank you for your contribution!

I would draw the negative slope in a different color ;)

Avatar
Ulises Cune

Hi Andrey,

Here is the improvement.

Image 6204

MA_Angle.ex5
MA_Angle.mq5

Avatar
Ulises Cune

This is how it would be used

Image 6210

Avatar
Ulises Cune

The indicator has an issue that does not "Refresh" when it is on a live chart, you have to press the "Refresh" button to show the value of the last candle. I don't know how to fix it, if anyone knows, can you help.

Image 6225

Avatar
Quote from Ulises Cune

The indicator has an issue that does not "Refresh" when it is on a live chart, you have to press the "Refresh" button to show the value of the last candle. I don't know how to fix it, if anyone knows, can you help.

Image 6225

Check indexes here:

for (int i = limit - 1; i >= 2; i--)

You need to calculate all the bars up to bar #0 and refresh it on every tick. With new bar arrived, you need update bar #1 and bar#0 again.
Look for example of indicators in mql5 codebase.