Double MA signal generator port from mq4 to mq5...

 

Hello All,

I am still struggling to port what I perceive as useful mq4 indicators to mq5. I had help on my last attempt but chose quite a complicated indicator and 'am saving it for later'.

This indicator is far simpler and I can tell from the debug I have included it is locating signals and processing data. All good. Except that it displays nothing 🙄.

I don't need to see the MA's on the chart so have made the MA buffers for calculation only, so was expecting to just see the trend arrows.

Please will someone take a look at what I have done and let me know what stupidity I have committed/ or what I have omitted; I will be very grateful.

I have attached both the original mq4 & my updated mq5 file.

With my best regards, ESB.

2 Moving Averages
2 Moving Averages
  • 2025.06.01
  • www.mql5.com
2 Moving Averages is a custom MQL4 indicator that uses two moving averages (fast and slow) to identify potential trend changes and generate buy or sell signals based on crossover points. It enhances signal reliability by optionally integrating support and resistance levels, helping traders confirm entry and exit zones. This tool is suitable for trend-following strategies and works across multiple time frames.
 

OK, I am glad no one has looked at this yet; I found an omission that was in the mql4 version, spcing a few points using _Point, MQL4 uses Point.

So I have arrows appearing, and I have added in MA lines to the chart make visual debugging easier; it is giving some very odd signals and I suspect my limit/rates total code.

WMBR, ESB.

Files:
 
Earthy Stag beetle #:

OK, I am glad no one has looked at this yet; I found an omission that was in the mql4 version, spcing a few points using _Point, MQL4 uses Point.

So I have arrows appearing, and I have added in MA lines to the chart make visual debugging easier; it is giving some very odd signals and I suspect my limit/rates total code.

WMBR, ESB.

Use rates_total - 1 as your limit, and return rates_total - 1 from OnCalculate(). There's no need for prev_calculated when you do that.

Also you need to iterate in reverse chronological order in your loop.

This all aligns with setting your buffers as series. See the attached mq5 file as a loop example.

   for(bar = limit; bar >= 0; bar--)
Files:
test_dots.mq5  10 kb
 
Ryan L Johnson #:

Use rates_total - 1 as your limit, and return rates_total - 1 from OnCalculate(). There's no need for prev_calculated when you do that.

Also you need to iterate in reverse chronological order in your loop.

This all aligns with setting your buffers as series. See the attached mq5 file as a loop example.

Thank you for taking the trouble to reply; Whilst I am not a noob in programming terms, I certainly am with indicators and have a lot to learn (always). I appreciate your guidance.

That did the trick - seems to work now! 😂

I will put back in some of the things I took out to simplify my task, and let the original author know/have the new code.

I am grateful!

With my best regards, ESB.

 
Earthy Stag beetle #:

Thank you for taking the trouble to reply; Whilst I am not a noob in programming terms, I certainly am with indicators and have a lot to learn (always). I appreciate your guidance.

That did the trick - seems to work now! 😂

I will put back in some of the things I took out to simplify my task, and let the original author know/have the new code.

I am grateful!

With my best regards, ESB.

You're most welcome. I appreciate your sense of humor.

By the way, there are loads of traders that learn to code EA's without touching indicators. The burning desire have a bot work round the clock is what it is, I guess.😂

"Managing Director at In between" 🤣
 

Attached is what I sent to Mir Mostofa Kamal.

Seems to work well, thanks for your help and hopefully it might be useful to someone else too.

With my best regards, ESB.

Files: