Portfolio Expert

The Portfolio Expert is the Portfolio in trading form: one MT5 Expert Advisor that trades every strategy of the portfolio on its own market, from a single chart. Where the page answers "what does one account do with these strategies", the Expert does it in a terminal, on live or tester data, with the account's real money, spread and margin.

The file is composed on the server from the strategies stored in this browser. Nothing of the portfolio's backtest travels with it: an Expert Advisor is a set of strategies, not a result.

At a glance

FactValue
PlatformMetaTrader 5 only — MT4 cannot host a multi-market Expert
Strategies per fileat most 50
Markets per fileone chart symbol plus as many polled markets as the portfolio spans
Attach toa chart of one of its own markets (pick the most liquid)
Account settingsapplied once, for the whole portfolio
Per-strategy settingseach strategy keeps its own
Downloadsthe source .mq5, or the compiled .ex5
Carries backtest figuresNo — importing one gives pending strategies

Before you export

  • The portfolio holds at least one strategy. An empty portfolio has nothing to compose, and the page says so instead of opening the dialog.
  • You are signed in: the Expert is composed on the server, so an export without a session is refused with "Sign in to export an Expert Advisor".
  • The MQL5 Export Options settings are the ones you want. The export bakes that page's account-wide protections and the stats panel once for the whole portfolio, so change them there first, not in the dialog.
  • You know your broker's symbol names. The app's market names and the terminal's symbols are not always the same: XAU/USD may be XAUUSD, EURUSD may be EURUSD.a.

Opening the dialog

Export → Portfolio Expert MT5 opens the dialog; it composes nothing until you press a download button. The dialog is a preview of the file, in four parts:

  • The count and the cap — for example "7 strategies on 4 markets - one Expert Advisor, at most 50 strategies". Above 50 the dialog shows a warning naming how many strategies to remove, and both downloads stay disabled.
  • The broker-symbol map — one row per market of the portfolio (see below).
  • The account-wide settings that will be baked, spelled out with their current values.
  • The two downloads — Download .mq5 (source) and Download compiled .ex5 — plus Close.

The broker-symbol map

Each row names the market as SBP knows it (EURUSD H1) and the broker symbol the Expert will trade there. The field already holds the market's own symbol; type over it when your broker spells it differently.

  • An empty field keeps the market's own symbol.
  • The map is stored in this browser, not inside the portfolio document: a broker's symbol names belong to a machine, not to a portfolio. Loading the same JSON on another machine starts with the app's names again.
  • A market that leaves the portfolio also loses its stored row, so a later strategy on that market does not inherit a stale symbol.
  • The map is part of the composed file, so changing it composes a different Expert (a new Expert ID) even when the strategies did not change.

Account-wide versus per-strategy settings

The wrapper — the part of the file that owns the account — applies these once for the whole portfolio:

SettingWhere it comes from
Max open positions, max open lotsMQL5 Export Options
Max daily loss, max daily drawdown, daily reset hourMQL5 Export Options
Minimum equity, maximum equity, maximum equity drawdownMQL5 Export Options
News filterMQL5 Export Options
Stats panelMQL5 Export Options

Everything else stays with the strategy it belongs to: its entry amount, its max spread (measured in its own market's points), its martingale, grid, add and reduce rules, break-even, trailing, sessions, trade-start settings and bar-close advance.

The practical consequence is the point of the whole design: one breached account limit stops every strategy's entries at once, and one stats panel on the chart reports the whole portfolio with a row per strategy — instead of several Experts each blocking only itself.

Downloading the source or the compiled file

  • Download .mq5 returns the composed source. Compose is fast; the file is written to your downloads as SBP Portfolio Expert 7 strategies.mq5.
  • Download compiled .ex5 asks the server's MetaEditor service to compile the same source and returns the ready Expert. It is slower (a full 50-strategy portfolio takes the compiler around 10–20 seconds), and the answer is cached, so a second download of the same file is instant. When the compiler is not available, the dialog says so — download the source and compile it in MetaEditor instead.
  • The identity is stable. The Expert ID (sbpp1-…) is the hash of the composed file, and the file carries no clock and no backtest numbers, so re-exporting an unchanged portfolio returns the same ID and stores nothing new. Changing the strategies, a magic number or the symbol map mints a new one.

Where to put it in MetaTrader 5

Attach the Expert to a chart of one of its own markets — the most liquid one, because everything else runs on that chart's ticks.

  • MT5 delivers ticks for the chart symbol only. The other markets are polled: on every chart tick the Expert asks each market for its latest tick and processes the ones that moved. A market with no tick in a bar is simply not traded that bar, so a quiet chart symbol delays every other market's decisions.
  • During OnInit the Expert selects every market and reads one close from it. That read is what asks the terminal (and the Strategy Tester) to load that market's history; a symbol the terminal does not have makes the Expert refuse to start and name the missing market in the journal.
  • Strategies whose exit point is Bar Close need a bar-close event, which MT5 does not raise; the Expert runs a one-second timer for them.
  • The Expert only manages its own positions: it identifies them by the strategies' magic numbers, so positions opened by your other Experts are never touched — but the open-position and open-lot caps still count the whole account.

What the file carries

  • Every strategy as a full SBP strategy block: its own market, its own period, its own magic number and its own // STRATEGY CODE line. Each one is the same code a single-strategy export produces, so a strategy behaves identically whether it is exported alone or inside a portfolio.
  • The portfolio document in a trailer at the end of the file: the portfolio name, its settings and every entry's market, magic number and strategy. There are no backtest figures and no balance lines in it.
  • The symbol map, so an import back into SBP restores the broker names the file was exported with.

Because the magic numbers travel unchanged, a deal found in the terminal's history can be matched back to the stored strategy that opened it.

How the protections behave in the Expert

  • The entry gate is the account's: when the open-position or open-lot cap, or the daily limit is reached, every strategy's next entry is cancelled with the reason in the order comment.
  • A breached daily loss or daily drawdown suspends new entries until the daily reset hour and closes the portfolio's own positions.
  • A breached equity protection (minimum equity, maximum equity, maximum equity drawdown) closes the portfolio's own positions and removes the Expert from the chart, with the reason printed on the chart and in the journal.
  • The news filter is one calendar read for the whole portfolio.

What it will not reproduce exactly

The terminal is not the page, and the differences are known ones. Read them before comparing the tester's report with the portfolio's figures:

  • Tick timing. A strategy on another market reacts on the first chart-symbol tick after its own event, so touch-based fills can differ by one tick. Bar-level decisions are the same.
  • Equity-percent and progressive-lots entry amounts. A strategy whose entry amount is a percentage of equity — or a lot size per account step — reads the account's equity inside the Expert, while the page ran that strategy on its own. Portfolios sized in lots or in a fixed currency amount add up; percentage and ladder sizing do not. The ladder's account step is a property of each strategy, so two entries can carry different steps.
  • Account-wide limits. The caps are account facts in the Expert and per-strategy facts in the page's separate backtests, so a full account changes the Expert's trade list and not the page's.
  • Margin. The tester enforces the account's margin; the page's aggregate does not model a shared margin. A "not enough money" journal line explains a lower trade count.
  • Swap and commission come from the terminal's symbol specification, not from the data set the page used.
  • The page's line is closed profit only, and multi-market profits were converted with this browser's snapshot rates, while the terminal reports its own account currency.

Importing a Portfolio Expert back

Import → Portfolio Expert reads a composed .mq5 and returns its strategies to the portfolio.

  • The picker accepts the source only. An .ex5 contains neither the source nor the strategy list, so it cannot be read back.
  • On a non-empty portfolio the page asks first, then replaces the set as one undoable step — Undo brings the previous portfolio back exactly.
  • The entries arrive pending, because the file carries no trades: press Calculate to run them and get the figures back.
  • The symbol map from the file is restored into your browser's map, so re-exporting keeps the broker names the terminal already knows.
  • A file that is not an SBP portfolio Expert, a wrong version, an unreadable strategy or a duplicated (market, magic) pair is refused with a sentence, and nothing is applied.

Limits and refusals

SituationWhat you see
More than 50 strategiesThe dialog names the cap and how many to remove; both downloads are disabled, and the server refuses the same request
Not signed in"Sign in to export an Expert Advisor."
Two strategies on one broker symbol with the same magicThe export is refused and names the pair — the same strategy tested on two markets has one magic number, so mapping both markets to one symbol is the usual cause
The compile service is disabled or busy"MQL5 compilation is not available yet" or "The MQL5 compiler is not available right now"; download the source and compile it in MetaEditor
Too many exports in an hour"Too many exports from this account. Try again later."
  • Portfolio — the page whose strategies the Expert trades.
  • MQL5 Export Options — the account-wide settings every export bakes.
  • Strategy Editor — where a single strategy is exported as its own Expert Advisor.
  • Data Horizon — the data window an export's trade-start time comes from.
  • Data Import — getting a broker's history into SBP so the strategies have data.