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.
One more silent problem showed up after the indexing was fixed. Right after a handle is created in OnInit, the indicator has often not finished calculating, so the first CopyBuffer calls return nothing useful.
In my case BarsCalculated came back as minus one on a cold start for the first tick or two. The converted EA read empty values as zero and fired a signal the original never gave.
Now I check BarsCalculated against rates_total before reading any buffer, and simply return if it is short. That one line removed a whole class of odd first bar trades.
The predefined Ask and Bid variables from MQL4 were another small trap. MQL5 wants SymbolInfoDouble or a tick structure, and a lazy wrapper that cached the price once per bar made my backtests look better than live.
For testing, I run the converted version in the tester on real ticks, not on generated ones. Generated ticks hid a one point difference in how the two versions handled the spread.
Did you also have to rewrite the prev_calculated logic, or did your indicators recalculate everything each call? Mine had to be redone for speed.