I've got this code calculating the moving average:
double ma1 = iMA(NULL, MA1_TTIMEFRAME, MA1_PERIOD, 0, MA1_METHOD, MA1_PRICE, 0);
How do I calculate whether the MA is pointing up or down? above 0 line or below 0 line? How to calculate its slope basically?
Thanks a lot
Here are many howto to calculate slopes!
To find out whether the ma goes up or down simply take the difference of two points of the ma. How to do it read the reference (put the cursor on iMA and press F1).
I am also interested this question and, trying to find the good post for this. Everybody who find the post, please kindly remind me.
SMMA is Smooth MA, not "slow" MA.
Also, your original query used the word "slope" (which usually infers the gradient of the slope), so you you were given the correct answer. "Angle" and "slope" are two different terms. They are not the same.
To convert a "slope" gradient into "angle" use: "angle = arctan( slope )". In MQL you can use the function MathArctan() to return the angle in "radians" and you will have to convert it into "degrees" using: "degrees = radians * 180 / pi" using the M_PI constant in MQL.
slope = (Y2-Y1)/(X2-X1)
the (X2-X1) is equal in all point of chart because the time frame is fix in one chart. foe example in 4 Hours time frame all 2 point in the chart will be 4 Hours. So you can ignore this part of above function and just use "Slope = Y2-Y1".
It is so easy. You just need to calculate:
Slope = MA candle - MA candle;
you can modify it for yourself and use it in your EA. for example the mode of MA, the period of MA (SlopeMAPeriod), time frame and so on.
In fact, the slope of MA is my trading strategy.