MT5 research beta · Expert advisor

TF Account Risk Guard for MT5

Monitor loss from a daily equity baseline and current-to-stop portfolio risk. Publish a pause signal for cooperating EAs with the same magic number.

MQL5 source, EX5, README and SHA-256 checksums. Research beta.

Concept illustration for TF Account Risk Guard for MT5; not a software screenshot
Concept illustration; not a software screenshot or a performance result.

What this MT5 EA does

  1. Records equity at first attachment during each broker-server day and persists that baseline locally.
  2. Adjusts monitored equity change for reported balance and credit deals after its baseline time.
  3. Adds current-to-stop losses across positions and flags positions whose stop risk cannot be quantified.
  4. Publishes a terminal-local pause expiry for the configured magic number; the supplied Position Manager and Session Breakout EA can read it.
  5. Optional emergency closure targets the configured magic number on hedging demo accounts only.

Inputs and default settings

These are the defaults in the supplied source. Review them for your account, exact broker symbol and intended test. They are not optimised trading recommendations.

Inputs in TFAccountRiskGuard version 1.0.0-beta1
InputDefault
CoordinatedMagic260916
DailyEquityLossLimitPercent3
PlannedStopRiskLimitPercent5
PublishPauseSignaltrue
EmergencyCloseDemoPositionsfalse

Limitations and failure conditions

  • The daily baseline is the first attachment of that day, not a reconstructed midnight balance. Start the guard before the trading session.
  • The pause does not block manual orders, unrelated EAs or another terminal. It is not an account-wide guaranteed loss limit.
  • Stop-risk estimates exclude gaps, costs and pending-order exposure; missing stops trigger the pause.
  • EmergencyCloseDemoPositions is false by default and is unavailable on netting or real accounts.
  • If the guard stops, exposure-based pause expires after ten server-time seconds; a daily-loss latch lasts until the next broker-server day.
  • Cash adjustments other than balance and credit deals are not classified separately. A positive equity is required at initialization.

Install in MetaTrader 5

  1. Extract the ZIP and read its README before attaching any file.
  2. In MT5, choose File → Open Data Folder. Copy the MQ5, EX5 and TFCommon.mqh files together into MQL5/Experts/TradeForex.
  3. Refresh Navigator and attach the EA to a chart in an isolated demo or tester. Review its inputs and data requirements.
  4. Use one instance per chart. Reattach after changing accounts; retain the documented state files and settings when testing restarts.

No broker password, web API key or DLL permission is required by this package.

Acceptance checks before relying on it

The following checklist is pending. It is not a report of passed runtime tests.

  • Compare the displayed baseline and cash-adjusted loss with a controlled demo ledger.
  • Check midnight rollover, restart, missing stops and changes in current-to-stop exposure.
  • Use a matching and a different magic number to confirm the pause is cooperative and scoped.
  • Test optional emergency closing only on disposable demo positions and verify unrelated tickets remain untouched.

Download contents and integrity

The ZIP contains MQL5 source, the compiled EX5, TFCommon.mqh, README.md, MIT licence, TEST-STATUS.json and SHA256SUMS.txt.

ZIP size: 26,056 bytes. SHA-256: b5ef16d2a4aa43b222fa08d242af6c8c7ba0402d98a82c084701f5fe3952b698.

Download EA source and EX5

See how we distinguish compilation, demo testing and trading evidence.

Frequently asked questions

Does this tool work in MT4?

No. This package contains MQL5 source and an EX5 build for MetaTrader 5 desktop. MT4 requires a different codebase; mobile and web charts do not run this desktop file.

What has been tested?

MetaEditor build 6180 compiled the supplied release with zero errors and zero warnings. The runtime acceptance checklist, backtests and forward tests are still pending.

Can it trade on a live account?

Order-changing functions in this release refuse real accounts and are disabled by default. Use an isolated demo or the Strategy Tester. The Execution Logger only records events and never sends orders.

Related tools and guides

Educational research, not personal investment advice. CFDs are leveraged products and can cause rapid losses. A calculation, indicator or stop cannot guarantee an account outcome.