MQL4 and MQL5 look similar, but several differences make direct conversion tricky.
Many converters and wrapper libraries exist that emulate MQL4 functions in MQL5. They speed up conversion, but they can hide differences in behaviour, so testing the converted code thoroughly remains necessary.
Main differences:
Indicator access: MQL4 calls iMA() and gets a value directly; MQL5 creates a handle and uses CopyBuffer().
Order functions: MQL4 OrderSend vs MQL5 trade requests or the CTrade class.
Series indexing: arrays in MQL5 are not series by default; ArraySetAsSeries is needed.
Events: OnCalculate signatures differ slightly.
Approach:
Convert logic step by step, testing each buffer against the original.
Compare outputs on the same data visually and numerically.
Have you converted code between MQL4 and MQL5, and what caused the most trouble?
Series indexing bit me harder than OrderSend ever did. I converted an MA crossover indicator, forgot ArraySetAsSeries on one buffer, and the visual looked almost right while every signal was one bar late.
Handles versus direct iMA calls are the other slow part. Creating the handle once in OnInit and copying buffers each tick is clear once you see it, but wrappers that hide that step made debugging worse for me, not better.
My rule now is convert one buffer at a time and print the first 20 values against the MQL4 original on the same history. If those match, I move on. If they do not, I stop and fix before touching the next buffer.
Events were milder. OnCalculate signature differences showed up as compile errors, so they were annoying rather than silent.
Has anyone found a converter that preserves series direction correctly out of the box? I always rewrote the indexing by hand in the end.