@Conor Mcnamara, while correcting your post to use a pocket instead of a link, the system removed the attachment (it is known bug but admin has yet to correct it).
Can you attach it again please?
Yes, for that reason I use the following macros when writing a common source for both MQL4 and MQL5 ...
// Define macros for array maximum and minimum #ifdef __MQL4__ #define ArrayMax( array, start, count ) ArrayMaximum( array, count, start ) #define ArrayMin( array, start, count ) ArrayMinimum( array, count, start ) #else #define ArrayMax( array, start, count ) ArrayMaximum( array, start, count ) #define ArrayMin( array, start, count ) ArrayMinimum( array, start, count ) #endif
Then I simply use ArrayMax() and ArrayMin() in my code and let the macros resolve things out for me.
@Conor Mcnamara, while correcting your post to use a pocket instead of a link, the system removed the attachment (it is known bug but admin has yet to correct it).
Can you attach it again please?
Here is that attachment
I also took a simple donchian channel indicator using ArrayMaximum and ArrayMinimum, and made a series version, so it will be easier to prove that these functions are indeed working properly in the MT4 way of indexing (when buffers are set as series). Check file "Donchian Channel Series"
My attempt. Looks plausible. I didn't study the code and spent about 15 minutes, there is a chance I missed something because of that. I haven't run this in the strategy tester.
The code is cross-platform. All changes are wrapped in conditional compilation directives (except for replacing IndicatorCounted() with prev_calculated).
My attempt. Looks plausible. I didn't study the code and spent about 15 minutes, there is a chance I missed something because of that. I haven't run this in the strategy tester.
The code is cross-platform. All changes are wrapped in conditional compilation directives (except for replacing IndicatorCounted() with prev_calculated).n
It seems to start showing an accurate zigzag
but then for the new swings, it doesn't look right:
I add this in OnInit to fix an issue that occurs with this zigzag drawing in mql5:
PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, 0.0);
I don't know what to say about this indicator, it looks like your conversion is fine and nothing much more can be done other than rewriting it completely (which wasn't the main interest), anyway one shouldn't stress about it. Have a good day.
I actually have it working correctly now, but I changed the logic such that all buffers are non-series. I worked on the code that Vladislav attached.
Unbelievably though, if you change the plot line width to 2 instead of 1, the entire zigzag collapses into a mess of arbitrary vertical lines. Could this be a bug?
I actually have it working correctly now, but I changed the logic such that all buffers are non-series. I worked on the code that Vladislav attached.
Unbelievably though, if you change the plot line width to 2 instead of 1, the entire zigzag collapses into a mess of arbitrary vertical lines. Could this be a bug?
For some reason PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE) does not work as I expected. The terminal still perceives EMPTY_VALUE as a value to be displayed. I develop mainly for MT4, and I had no experience with DRAW_ZIGZAG before this.
I just replaced all "EMPTY_VALUE" with "0.0" in the code and it seems to display correctly now (I attached AutoScaleZZ2_fixed.mq5). I wish I had run the indicator in the strategy tester that time.
For some reason PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE) does not work as I expected. The terminal still perceives EMPTY_VALUE as a value to be displayed. I develop mainly for MT4, and I had no experience with DRAW_ZIGZAG before this.
I just replaced all "EMPTY_VALUE" with "0.0" in the code and it seems to display correctly now (I attached AutoScaleZZ2_fixed.mq5). I wish I had run the indicator in the strategy tester that time.
There are still some complex issues with the series version, and not to do with the plot, but the fact that it's not finding the true peaks and bottoms. I'm not sure why exactly, but I appear to get it working perfectly now when not setting the buffers as series, check "AutoScaleZZ4"

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I set out to do a practice conversion to convert a more tedious MQL4 indicator to MQL5. This wasn't for anything other than practice, and because I'm focusing on MT5 now. I thought, maybe I can do it in 30 minutes... but no, this wasn't the case at all.
I have tried numerous times to convert it properly now but there is no positive outcome with this.
Before I show my attempt, it should be noted that ArrayMaximum and ArrayMinimum have a different function definition between MT4 and MT5:
MT5:
MT4:
(so don't get this mixed up if you decide to look at this)
I don't have that much experience at all with MQL4, but I know some of you have a lot of experience.
The indicator in question is here:
The author himself doesn't deal with MT5. I'm frustrated to see that I'm unsuccessful to convert this MT4 indicator properly, and I would like do see the issue (for education sake).
I've achieved at least a plot, on EURUSD, but it's clearly not looking right:
I attached my attempt to convert this indicator