I would like to code a rough gradient in a moving average. My clumsy idea was to try code the SMA, must be higher than SMA of 5 periods ago plus a value, which is X below.
The best way to measure a gradient is with a ratio of y and x.
1
2
3
4
5
c=100
x=5
y=average[c]-average[c](close[x-1])
Ratio=(y/x)
Negative ratio results are a downward sloping MA and the lower the number the steeper the angle. Positive ratio results are an upward sloping MA and the greater the number the steeper the angle.