Export Full, Editable MQL5 Source Code From a Strategy Builder

Every strategy you approve in AlgoLens Factory exports as one plain-text .mq5 file: the full MQL5 source, with the rule written out in a comment, every setting as a named input and the entry, exit and risk logic in readable functions. It has no license check inside, it compiles in MetaEditor like any EA you wrote yourself, and under the license agreement it is yours to keep, change and sell.

File
One .mq5 source file (FL_<number>.mq5), plain text
Dependencies
None beyond MetaTrader’s standard Trade library
Inside
The rule in plain English, inputs, signal and exit functions, position sizing
License check
None. Exported files keep working after your license ends
Ownership
Yours: use, change, publish, share or sell (EULA section 4)
Trial
Code of up to 3 different strategies, no card

Facts checked against the app and its license on November 9, 2026.

What the file contains

A strategy builder that hands you only a compiled .ex5 leaves you with a black box: you can run it, but you cannot read why it trades. The Factory exports the source. Here is the top of a real export, abridged:

FL_249.mq5 · header and inputs, abridged
//+------------------------------------------------------------------+
//| FL_249.mq5 — generated by AlgoLens Factory
//|
//| RULE (en):  BUY when price crosses below smoothed moving average(200)
//|             AND Vortex(25) VI+ crosses below 0.9; SELL on the mirror
//|             · stop 3×ATR · target 2.5R
//|
//| HEDGE account: each order becomes its own position (identified
//| by magic). This is the mode this EA was tested in.
//|
//| Parity: the decision is read on the CLOSED BAR (shift 1) and the
//| order goes in at the open of the next bar — exactly as in the
//| backtest that approved this strategy.
//| Do not hand-edit: use the AlgoLens Factory Strategy Tuner, which
//| revalidates and regenerates this file.
//+------------------------------------------------------------------+
#property version   "1.00"
#include <Trade\Trade.mqh>

input double InpLots      = 0.1;
input long   InpMagic     = 5000249;
input double InpSLval     = 3;      // stop = N x ATR(14)
input double InpTPval     = 2.5;    // target = RR x risk (stop)
input int    InpMaxBars   = 48;     // time-based exit (in bars)
input int    InpATRPeriod = 14;
// --- entry order: 0=market 1=stop (breakout) 2=limit (pullback) ---
input int    InpEntryOrder    = 0;    // how it enters when the signal fires
// --- dynamic exits (0/negative = off) ---
input double InpTrailxATR     = 0;    // trailing: distance xATR (0 = off)
input double InpBEbufxATR     = -1;   // break-even: buffer xATR (negative = off)
// --- position sizing (same as the backtest): 0=fixed 1=risk% 2=risk$ ---
input int    InpSizing    = 1;        // 0=fixed InpLots 1=% of equity 2=$ per trade
input double InpRiskPct   = 1;        // % of equity risked per trade (sizing=1)
// --- execution guards (0/24 = off) ---
input int    InpMaxHoldDays    = 10;  // closes after N calendar days in the trade
input int    InpFriNoEntryHour = 17;  // Friday: no NEW entries from this hour on
// ... signal functions, exits, OnInit and OnTick follow

Reading the file from top to bottom:

  • The header states the rule in plain words, the account mode it was tested in and when it decides: on the closed bar, with the order at the next bar’s open, as in the backtest.
  • The inputs carry every number the tests approved: stop and target, time exit, entry order type, trailing and break-even, position sizing and execution guards such as the Friday cut-off.
  • The signal functions compute the entry and exit conditions from MetaTrader’s built-in indicators and the price bars. No custom indicator files.
  • OnTick acts once per new bar: it manages the open position (break-even, trailing, time and Friday exits) and places market or pending orders with their stop and target.

The file also checks the account it lands on. It compares the account currency and contract with the one the strategy was mined on, adapts money values on a cent account, works out the broker’s time zone from its bars, and writes the reason to MetaTrader’s journal whenever it holds back a trade.

The Code tab of strategy 5751 in AlgoLens Factory: the MQL5 header with its origin, the rule in English and Portuguese, the hedge-account note, the parity note and the server time zone note
The Code tab of another approved strategy, FL_5751, in the Factory: the same source that goes into its .mq5 file, rule and time-zone notes included.

From export to the Strategy Tester

  1. Export the strategy

    In the strategy’s report, export it. The Factory writes FL_<number>.mq5.

  2. Open it in MetaEditor

    Put the file in your terminal’s MQL5\Experts folder (File, Open Data Folder in MetaTrader 5), open it in MetaEditor and press Compile. You get the .ex5 next to it.

  3. Run it in the Strategy Tester

    Pick the same symbol and timeframe the strategy was built on. The header names them; on any other chart it would be trading something else.

  4. Compare with the Factory’s backtest

    The Factory already compared its backtest with the exported .mq5 trade by trade before handing it over. Your own test run is the second check.

Illustration of the three steps after an export: the FL_249.mq5 file, compiling it in MetaEditor with 0 errors and 0 warnings, and running it in the MetaTrader 5 Strategy Tester on GOLD M30
Illustration of the three steps, not a screenshot of MetaTrader: export the file, compile it in MetaEditor, run it in the Strategy Tester.

Why the exported EA trades like the tested strategy

The weak spot of every strategy builder is the gap between its own backtest engine and the EA it writes. A condition that becomes a slightly different condition in MQL5, or a pending order placed on the wrong side of price, and the EA in your account is no longer the strategy that passed.

The Factory compares its backtest against the exported .mq5, trade by trade. That is how six kinds of divergence were found and fixed, among them an “at least 50%” condition that had become “all of them”. If a building block could not be reproduced exactly in MQL5, the export is refused rather than approximated.

What you may do with the code

The AlgoLens Factory license agreement settles it in section 4, “Your EAs are yours”:

  • You own the EAs you generate, including EAs exported during a trial. AlgoLens claims no rights in them.
  • You may use, change, publish, share, sell or license them, for any purpose, including commercial use, during and after your license.
  • The template code inside them comes with a perpetual, irrevocable, royalty-free license, which does not end when your Factory license ends.
  • The file carries a comment saying it was generated with AlgoLens Factory, and you may remove it.
  • You may not take the templates out of the Factory to build a product that generates strategies.

Exporting needs a valid license. Files you already exported do not: they are ordinary files and keep working in MetaTrader 5.

Questions

Is it the .mq5 source or only a compiled .ex5?

The .mq5 source, as plain text. You compile it yourself in MetaEditor, which turns it into the .ex5 that MetaTrader 5 runs. The Factory never hands out a compiled-only file.

Does the exported EA check my license or stop working when my license ends?

No. The file has no license check, machine lock, expiry date or connection to AlgoLens. Once exported, it is an ordinary file that keeps working in MetaTrader 5. What needs a valid license is exporting or viewing code inside the Factory.

Can I sell or share an EA I exported?

Yes. Under the Factory license agreement (section 4) the EAs you generate are yours, including those exported during a trial: you may use, change, publish, share, sell or license them, commercially too. The code inside them comes with a perpetual, royalty-free license. What you may not do is pull the templates out of the Factory to build a product that generates strategies.

Does it need extra files, DLLs or custom indicators?

No. It is one self-contained file. The only include is MetaTrader’s standard Trade library. Strategies from the Asset pair family read a second symbol from your terminal, so that symbol has to exist at your broker.

How many strategies can I export during the free trial?

In the trial without a card, the code of up to 3 different strategies. Exporting the same strategy again, or viewing its code again, does not count. Exporting during that trial needs an internet connection so the count can be checked.

Can I edit the code by hand?

Yes, it is yours. The file’s own header recommends changing a strategy in the Factory’s Strategy Tuner instead, because the Tuner reruns the tests and regenerates the file. A hand edit means the file is no longer the exact strategy that passed.

Try it on your own setups

14-day free trial with every feature, no card. You can export the code of up to 3 different strategies during the trial. Windows 10 or 11 and MetaTrader 5.