# Forex Slope Moving Average Indicator

# MetaTrader Slope Moving Average Indicator

## We have design many trading system that use a *slope moving average indicator* and in this blog article we will explain and show you how to build your own Slope indicator using the Metatrader 4 Platform.

But first let me explain exactly what is the slope of the line?

The slope of a line in the plane is defined as the rise over the run, m = Δy/Δx.

In mathematics, the slope or gradient of a line describes its steepness, incline, or grade. A higher slope value indicates a steeper incline. (Slope, as a practical term, is not defined for theoretically perfectly horizontal or vertical lines.)

### The slope moving average indicator is normally described by the ratio of the “rise” divided by the “run” between two points on a line. The line may be practical – a set by a road surveyor – or in a diagram that models a road or a roof either as a description or as a plan.

Mathematically, angle has no meaning on a graph where the axes have different units, in this case price and time. If you want meaningful values use slope.

In this case, *slope moving average indicator* has units of price/time (or points/time) and it stays the same regardless of scale of the axes. If you have a line with a of slope 10 points per bar then drag the scale, the visible angle changes but the value of the slope stays the same, i.e. 10 points / bar.

Now lets look at some code in MetaTrader 4 to explain the formula for the **slope moving average indicator**.

First we start with 2 Moving Averages using Custom Indicator Function.

MA1 = iMA(NULL, 0, MAPeriod, 0, MA_Mode,PRICE_MEDIAN, EndMAShift );

MA2 = iMA(NULL, 0, MAPeriod, 0, MA_Mode,PRICE_MEDIAN, StartMAShift);

Lets define the Rise Δy or the different between the moving averages

Rise = MA1-MA2

The run Δx the different between two point in bar time

Run= EndMAShift – StartMAShift

**Slope = Rise/Run**

We can get the value of the angle by 10000.0 : Multiply by 10000 so that the Angle is not too small for the indicator Window.

Take ArcTan of value to get the angle in radians and convert to degrees

*ConvertToDegrees* = 3.14159/180.0;

Angle = 1000 * MathArctan(Angle)/ ConvertToDegrees ;

Depending on the Currency Pair you will have to compensate for the multiplier for JPY

To 10 instead of a 1000 .

By having this type of indicator or function built into your trading system can better filter out bad trades.

If you would like to receive a copy of the slope moving average indicator please go to our website http://expertadvisorprogramming.com to download your copy of the slope moving average indicator today!