is MACDArray a series array like the doc says?
Spot on!
Thanks!!!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi there,
This is actually a sub question related to https://www.mql5.com/en/forum/144912.
Anyway, the big picture is that I'm trying to check if the previous macd < previous signal and if current macd > current signal. To do that I need to make sure I'm calculating the MACD and signal values correctly and am comparing my results with the MACD indicator that comes with MT4 except I've changed the style from histogram to line. The signal mode in the indicator is SMA although the MACD is calculated using EMAs. My signal values differ from the indicator's signal values as shown below.
In the chart the red vertical line is on bar 1 i.e. the current finished bar. The Data Window shows the MACD value of the indicator is -0.000582 and in the Journal tab below where the highlighted row has printed the CurrentMACD I have -0.00058180, which matches but for rounding. However, the signal values differ. The Data Window has -0.000219 which is in the row under the highlighted row as PreviousSignal. Not easy for me to get my head around how THAT happened.
The function I have for this is:
So I'm filling up the MACDArray with 10 indexes of MACD values. The first index i.e. 0 contains the MACD for the bar at position 1, so for the last parameter in the iMA function I've set the shift to i+1. Then, in the CurrentSignal and PreviousSignal variables, the last parameter of the iMAOnArray function points to the first index of MACDArray. To me this should all make sense but it obviously doesn't so any assistance would be appreciated.
Thanks!
Btw, I've declared the MACDArray in the global area as: