Magnet EA Source Code, free MQL source code for MetaTrader

Magnet EA Source Code

Magnet EA Source Code, free MQL source code for MetaTrader

This page gives you the Magnet EA free source code, the .mq5 file itself and not a compiled robot you have to trust. Under the hood it runs mean reversion (gaps), with each step visible in the code.

  • Platform: MetaTrader 5, a single .mq5 file
  • Strategy: mean reversion (gaps)
  • Price: free, a free account is all you need
  • Licence: study it, edit it and, if you want, rebrand it

In short, you get exactly the file we publish, and therefore nothing stops you from rebuilding any part of it.

How the Magnet strategy works

Mean reversion assumes that a price stretched far from its average tends to come back, so the robot sells strength and buys weakness. It wins often and loses big when a real trend starts, which is why the stop is the part of the file worth reading twice.

A gap is the space between one close and the next open, and price fills a good share of them within the following sessions. The robot measures the gap, waits for the market to settle and trades the return towards the old level.

The whole decision lives in one function, so you can follow it from the first condition to the order that gets sent.

What is inside the Magnet EA free source code file

  • The distance measure, where the robot decides that price has stretched far enough.
  • The gap detection, with the minimum size that makes one worth trading.
  • The risk block, with the lot sizing, the stop loss and the take profit.
  • Finally, every input with its default value, so you can compare it against your own broker.

How to compile and run it

  1. First, download the .mq5 file from the button at the end of this page.
  2. Then open MetaEditor 5 from MetaTrader 5, with F4 or the editor button.
  3. After that, save the file inside MQL5 and then Experts, and press Compile.
  4. Finally, refresh the Navigator and drag Magnet onto a chart.
  5. Run it on a demo account first, and read every input before you go live.

If the compiler complains, our guide on compiling MQL source covers the usual causes. In most cases it is simply a missing include or the wrong folder.

What you can change

Widen the distance it demands and the robot trades less and survives longer. That single change usually matters more than any indicator swap.

Before any of that, however, look at the risk block. After all, a good entry with the wrong lot size still empties an account, and therefore the sizing deserves the first pass rather than the last.

More robots like this one are in the free EA source code library, and the paid catalogue with documentation and support lives in the MT5 source code section. The idea behind mean reversion is explained well on this reference page.

Questions about the Magnet EA free source code

Which platform is it for? MetaTrader 5, one .mq5 file with no dependencies to hunt down.

Can I run it on several pairs? Attach it to one chart per pair and give each one its own magic number.

Can I change the logic? That is the whole idea. The entry and the exit sit in separate functions.

Is there support? The free library comes as it is. The paid catalogue is the one that ships with documentation.

Download the Magnet EA free source code

The file below is the complete .mq5. First of all, create a free account or log in. Then download it and, finally, open it in MetaEditor 5.

Free source code. Log in or create a free account to download the Magnet EA Source Code source files.

Login to Download

Shopping Cart
Assistant 🔊 – ✕
← My conversationsEnd chat