PositionRelay logoPositionRelay

Docs / MT5 Optimizations: setup and user guide

Optimizations

MT5 Optimizations: setup and user guide

Set up your self-hosted MT5 worker, run an optimization, and understand the dashboard controls, progress, and results. Available with Pro or Ultimate.

What is MT5 Optimizations?

MT5 Optimizations lets Pro and Ultimate subscribers run batch forward optimization of their own Expert Advisors from the PositionRelay dashboard. A Docker worker on your computer polls the cloud every few seconds and executes Start, Stop, Resume, and Clean commands.

You provide the EA (.ex5), parameter grids (.set), and an MT5 broker account (demo or live). Results land in a host reports folder and sync back to the dashboard as passes and favorites. Company portfolios need the source code of the supported portfolio EA.

This feature is self-hosted. PositionRelay does not run MetaTrader for you. There is no hosted optimizer today.

How it works

The published Wine + MetaTrader 5 Docker image runs on your machine. The heartbeat process authenticates with your PositionRelay User ID, checks Pro or Ultimate access, and waits for dashboard commands.

When you start a run, the worker launches Strategy Tester jobs for the symbols and timeframes you selected, using your Classic parameter grids. Validated survivors appear under Passed and Favorites. A company portfolio can be built from favorites only when the source code of the supported portfolio EA is available.

  1. Subscribe to Pro or Ultimate and open Dashboard → Setup → MT5 Optimizations.
  2. Install Docker and follow the setup wizard for your operating system.
  3. The wizard shows the exact folders, files, and commands to copy.
  4. Check the first-start logs for broker authorization, then confirm the worker shows online on Dashboard → Optimizations.
  5. Configure dates, symbols, and timeframes, then Start a run.

Requirements

  • Active PositionRelay Pro or Ultimate subscription.
  • An x64 computer running Windows, Linux, or Intel macOS with Docker. Apple Silicon / ARM is unsupported.
  • Enough RAM and disk for real-ticks history (configure Docker Desktop resources if you use it).
  • An MT5 broker account, demo or live (login, password, server).
  • Your own compiled EA (.ex5). MQL5 Market EAs are activation-locked and will not run.
  • Parameter grids as .set files in the SetFiles/Classic/<timeframe> layout the wizard describes.

Installation

For the default account, fill MT5_COMPANY in optimizer.env with the full company string MT5 reports for that account — the same Company field on HTML optimization reports, including spelling and case. Do not use a short brand nickname: FTMO fails when MT5 reports FTMO Global Markets Ltd. To add more accounts, save Broker/accounts.json in the host folder with an accounts array; each entry needs a unique id, company, server, login, and password. Use one account per company, copy company/server exactly from MT5, and keep the file on your computer. The setup wizard has a copyable example. Restart the container after editing accounts.json; optimizer.env remains the active default after every restart.

The step-by-step installation lives in one place: the setup wizard in your dashboard. It matches commands, folders, and file paths to your operating system and fills in your User ID.

Where your files live: option 1 is a folder on your own computer (C:\PositionRelay\optimizer on Windows, $HOME/PositionRelay/optimizer on Linux and macOS) holding your EA, set files, Broker/servers.dat, optional Broker/accounts.json for extra broker accounts, and optimizer.env. It is the only option today, and the wizard uses it. Option 2, uploading your EA, set files and env variables to PositionRelay, is coming soon and will be at your own risk.

Open Dashboard → Setup → MT5 Optimizations and follow the steps in order.

Each -v mount for Experts, SetFiles, Broker, and reports has your computer's folder path on the left and a /data/... container path on the right. If your files are elsewhere, replace each full host path, including the drive letter on Windows. Changing --env-file alone does not change those mounts.

In a working MT5 terminal, choose File → Open Data Folder. Copy config/servers.dat into your optimizer Broker folder so the Docker terminal can find your broker. Copy only that file; accounts.dat contains account data. The setup wizard shows the exact destination.

On the first start, broker login runs before the heartbeat and can take several minutes. Follow the container logs in the setup wizard. After the log says "Starting optimizer heartbeat", allow a few polls for the worker to show online on the Optimizations page.

  • Never commit optimizer.env.
  • Experts and SetFiles are mounted read-only; reports are writable.
  • The MT5 tree and tick cache live on the named volume positionrelay-mt5.

Run from the dashboard

Choose a configured broker in the Optimizations selector and wait for activation to finish. Choose symbols from that broker's MT5 catalog, then press Start; none are selected initially or after a switch. Switching is disabled while the worker is busy. A history-only broker shows past results but cannot Start, Resume, or build a portfolio. If Docker is offline, the last catalog is marked stale and work is disabled.

Open Dashboard → Optimizations. Choose the date range, symbols, timeframes, optimization mode, balance, and max equity drawdown. Optionally enable the robustness check after validation.

Start begins a new batch. Resume continues an interrupted optimization run. Stop cancels the current worker job (optimization, robustness check, portfolio build, favorites sync, or broker switch) when the worker is online; the worker stays online. Update and recreate the worker before relying on Stop for that cancel behavior—existing workers may leave interrupted non-optimization commands processing. Clean clears tester cache artifacts on the host and is meant for idle workers.

Live status refreshes every few seconds while the page is open. Keep the container running for the duration of the job.

Use the optimization dashboard

  1. Select a configured broker and wait for activation. Confirm the worker heartbeat is alive.
  2. Set the dates, symbols, timeframes, test balance, currency, and drawdown target. Start with a small selection; more combinations take longer.
  3. Press Start once. Watch the worker activity and queued commands, then the run progress. The page refreshes every 10 seconds; keep Docker running.
  4. Review Recent pass/fail and Passed. Open a report, request a robustness check if needed, then add favorites after the batch finishes.
Use the optimization dashboard
Example dashboard with demonstration data. Open the picture to zoom in; your broker, settings, and results will differ.

Read the worker and run status

Heartbeat: alive / stale
Alive means a recent worker ping; it does not prove broker login or a job succeeded. Stale means no recent ping. Check Docker and the connection before sending more commands.
Optimizer: Idle / Offline
Idle means the worker is online with no reported activity. Offline may include the last known activity; that is historical, not proof work is still running.
Optimizer activities
Optimizing runs the batch; Moving favorites updates host files; Syncing favorites reconciles the saved selection; Building portfolio generates the company portfolio; Switching broker activates an account and refreshes its data; Robustness check stress-tests a result; Stopping interrupts work; Cleaning removes optimization artifacts. Worker busy is a generic activity from older workers.
Starting… / Queued…
Starting means a command is processing before a named activity appears. Amber Queued lines show commands waiting, with a count when repeated; Stop is listed first. Queued does not mean completed.
Last ping
Time of the latest heartbeat. Dashboard timestamps, including result times, are displayed in UTC using your language's date format. A dash means no timestamp is available.
Optimization run / Last optimization run
The first describes the current active batch. The second is retained history: a pending or failed old run can appear while the worker is doing something else. Read Optimizer for current activity.
Run status
pending = created, awaiting execution; running = batch in progress; completed = batch finished, not a promise every strategy passed; stopped = interrupted; failed = ended with an error. Read the error below the run for details.
Progress and job details
A percentage and completed/total jobs describe batch progress, not estimated time. Progress unavailable means the worker has not supplied it, not 0%. The detail line identifies the current symbol, timeframe, parameter file, and phase when available.
On a phone: Expand / Close
The sticky worker strip shows live activity and Stop. Expand opens full status and Start, Resume, Stop, Clean controls. Close or Escape returns to the page.

Choose the right action

Start
Creates a new batch from the visible settings. Requires an available worker, a ready configured broker, selected symbols, and allowance. Wait while its spinner is shown; a command-completed notification acknowledges the command, not the entire batch.
Resume
Continues an eligible stopped or failed run for the active broker using that run's frozen settings. Form edits are ignored. The resume hint identifies the run. If none is eligible, Resume is disabled.
Stop
Interrupts any current worker job, including optimization, robustness, favorites, portfolio, or broker switching. Requires a busy worker with a live heartbeat. The container stays online. Older workers need an update and recreation for cancellation of non-optimization jobs.
Clean
A reset, not a refresh: stops work and deletes host tester cache, generated reports, and optimization artifacts. Across all brokers for your user, it removes non-favorite results and runs that no favorite needs. It also deletes all portfolios and saved Start settings. Saved favorites and their linked result/run records are retained in the dashboard; local report files can still be removed. Save needed reports first. Available only when idle; consumed allowance is not restored.
Monthly allowance
Pro allows one new Start per billing month; Ultimate has no new-Start limit. A queued Start reserves the slot, and an accepted run consumes it. Resume does not use another slot. When exhausted, wait for reset or change plan. Clean does not reset the quota.

Choose broker and optimization parameters

Broker
Selects the company whose results you see and the configured account used for new work. Wait for switching to finish. Switching is unavailable while busy. A history-only entry allows browsing old results, not Start, Resume, or portfolio rebuild. A stale or missing catalog needs an online worker and successful broker activation.
From date / To date
Use MT5 format YYYY.MM.DD, for example 2020.01.01 to 2026.10.31, with From before To. This is historical test data, not a schedule. Initial defaults span the last 12 years.
Symbols
Choose instruments from the selected broker's catalog. Search appears for long lists; All selects the entire catalog, Clear removes the selection. N selected is a count, not a job total. Choose at least one. Switching accounts resets the selection before any saved settings are restored; unavailable symbols are excluded.
Timeframes
M5 = 5 minutes, M15 = 15 minutes, H1 = 1 hour, H4 = 4 hours, D1 = 1 day, W1 = 1 week. Select one or more; All and Clear affect this list. M5/M15/H1/H4 are initial defaults. The worker needs matching Classic parameter grids for the chosen timeframes; there is no strategy selector on this page.
Optimization mode
Slow complete tests all parameter combinations in the grid; Fast genetic searches a subset using MT5's genetic algorithm. Fast genetic is the initial default. Duration depends on your grids, history, and computer.
Currency / Account balance
Simulated tester account currency and starting balance, not your live funds. Choose USD, EUR, GBP, CHF, JPY, AUD, CAD, or NZD and a positive balance. Initial defaults are USD and 100000.
Max equity drawdown %
The risk-scaling target for validation, initially 15%. It is not a live-account loss limit. The post-scaling rejection ceiling includes 12% headroom: a 15% target gives a 16.8% ceiling.
Run robustness check after validate
Checked by default. Runs extra stress tests after validation and takes longer. If unchecked, surviving rows can still be checked later using Robustness check; yellow rows indicate a pending robustness check.
Saved settings / disabled fields
Settings from an active or resumable run are restored first, otherwise the last accepted Start for that account. Idle edits are preserved during polling. Busy workers lock the fields; changes apply to a new Start, never to Resume's frozen settings.

Understand results and table controls

Recent pass/fail
Latest events for the selected company. Green Passed = accepted; amber Low return = soft low-return rejection; red Failed = failed/rejected. Reason explains why. A job-complete event is not an individual strategy report; its metrics can be blank. Empty tables mean no matching results yet.
Strategy / Symbol / TF / Profile / Pass
Strategy identifies the instrument, timeframe, and tester pass. Symbol is the broker instrument; TF is the chart interval; Profile identifies the parameter profile; Pass is the tester pass number, not a pass/fail grade. Time is when the result was recorded.
Return on risk / Sharpe / Trades / Net profit
Return on risk = net profit % divided by equity drawdown %. Sharpe describes risk-adjusted returns; Trades is total trades; Net profit uses the report's amount/percentage text. A dash means missing data, not zero. These are historical test results.
Passed / Open
Passed contains validated survivors for the company. Open, or a linked strategy in Recent, opens the detailed report, metrics, parameters, and chart. A yellow row still awaits robustness checking.
Robustness check / Robust
Robustness check queues stress testing; Queuing is the request in progress. Robust means the check passed and the button is disabled because it is complete. Queueing success is not a passed test; wait for refreshed results.
Favorite / Remove
Favorite adds a result to the company's saved selection and triggers worker synchronization. Adding is disabled during a batch or if the report has no company. Saving/Removing indicates a pending request; Remove removes the favorite, not the original result.
Portfolio / Rebuild / View portfolio
Favorites can feed a company portfolio. Building means wait; Offline needs the worker restarted; Failed allows retry when the broker is ready. Rebuild requests generation; View portfolio opens an existing build. This needs the supported portfolio EA source, absent from the public image: an arbitrary compiled EA cannot build portfolios.
Parameter usage
All = all passed rows; Robust = those that passed robustness; No robustness check = passed rows awaiting a check. Parameter and Value identify an input choice; Count counts its occurrences, Symbols/TFs list where it occurs, and % is its share within the selected group. Tabs change only this table. Swipe tables horizontally on a phone to see all columns.

If something looks stuck

Start is disabled
Check pending requests, worker activity, broker readiness, selected symbols, and monthly allowance. Finish or stop current work before starting another batch. Read any broker error shown below the selector.
Resume or Stop is disabled
Resume needs an eligible run and a ready broker. Stop needs both a busy worker and a live heartbeat; an old pending run alone does not enable it. Restore Docker connectivity if stale.
Command failed / worker offline
Read the error notification and worker logs before retrying. Keep Docker and your network running, allow a few refresh cycles, and confirm the broker activated. A worker heartbeat alone does not confirm broker authentication.
No results / progress unavailable
Check the selected broker, wait for the worker to report jobs, and inspect the current phase or error. A historical run status is separate from live activity. Use the installation and troubleshooting sections below for worker setup problems.

Results, favorites, and portfolio

Passed rows are validated survivors from the batch. Mark favorites in the dashboard; the worker can sync them into the Favorites folder on the host.

Company portfolios currently support only one PositionRelay portfolio EA and need its source code, which the public image does not include. With your own compiled .ex5 you can optimize, validate, and favorite, but not build portfolios.

Reports are also written to the reports folder you created on the host.

Updating the image

To check for a newer image, run docker pull ghcr.io/razvantomegea/position-relay-portfolio-optimizer:latest (the Download command in the setup wizard). Pull status only describes the local image—not whether the running container already uses it. Compare docker inspect --format '{{.Image}}' positionrelay-optimizer with docker inspect --format '{{.Id}}' ghcr.io/razvantomegea/position-relay-portfolio-optimizer:latest. If they match, leave the container running. If they differ—or you already downloaded one earlier and deferred recreation—wait for any active run to finish, then recreate the container with the commands in the last step of the setup wizard. An image update replaces the worker software only; host folders and the positionrelay-mt5 volume keep your EA, grids, reports, MetaTrader 5 install, and tick cache.

A newer MetaTrader 5 build is not applied automatically. The wizard explains how to refresh it once while keeping your data. Changes to optimizer.env also need a new container; an existing container keeps its original environment.

Troubleshooting

  • Worker stays offline — confirm Pro or Ultimate is active, POSITIONRELAY_USER_ID matches Setup, and docker logs show the heartbeat polling.
  • Broker login not confirmed — check Broker/servers.dat from your working MT5 terminal, then MT5_LOGIN, MT5_PASSWORD, and MT5_SERVER. Keep all three in optimizer.env (account id default after every container restart). Optional extra accounts go in Broker/accounts.json (one per company; never put passwords in the web app). The entrypoint copies active-account credentials to /dev/shm and unsets the password from the worker process only.
  • MT5 company … does not match configured … — set MT5_COMPANY or accounts.json company to the full company string MT5 reports for that account (same as the Company field on optimization reports). After changing MT5_COMPANY in optimizer.env, recreate the container so the new environment value is applied before verification. Brand nicknames fail (e.g. FTMO when MT5 reports FTMO Global Markets Ltd).
  • Wine may print fixme messages, ALSA "cannot find card" lines, and graphics-library errors during first login. Those lines alone do not confirm success or failure. Look for "Broker login authorized" or "broker login not confirmed", then "Starting optimizer heartbeat". A worker can be online even when broker login failed.
  • EA will not run — Market-purchased EAs are activation-locked. Use your own compiled .ex5.
  • Out of disk / slow ticks — raise Docker Desktop Resources and free space for real-ticks history.
  • Apple Silicon / ARM — unsupported. Use an x64 computer.
  • Command failed on the dashboard — open docker logs -f positionrelay-optimizer for the worker error.

Docs