Loading…

Compliance Ready Template

Funded/prop-style accounts are usually governed by rules the EA's own strategy logic has nothing to do with - a daily loss cap, a maximum drawdown from the account's equity peak, a cap on trades per day, a trading-hours window, and often an external emergency stop the trader (or the firm) can trip independently of what the EA is doing. Bolting these checks onto an existing strategy after the fact tends to miss cases, because each one gets added reactively after a specific rule was already broken once. This template inverts that: FirstBlockedGateReason() runs every gate in one place, before any signal is allowed anywhere near OrderSend, and the demo strategy (EvaluateDemoSignal, a plain SMA crossover) is the only piece meant to be swapped out. Every gate decision is written to the audit CSV, including the blocked ones - a reviewer asking "why didn't this account trade at 14:02" needs the BLOCKED row and its reason (which gate, and by how much) as much as the FILLED rows. The gates run cheapest/most-likely first: kill switch, AutoTrading state, trading window, daily loss percentage against the day's starting equity, overall drawdown percentage against the tracked equity peak, trades-opened-today count, and open-position count for this magic - the first one that fails is the one logged and shown on-chart. The kill-switch convention (a KILLSWITCH_ACTIVE GlobalVariable) is deliberately identical to this catalogue's KillSwitchProtocol Library and KillSwitchListener EA, so a switch tripped from either interoperates with this EA out of the box. It is not #included from either, though - every CodeBase submission stands alone (house style section 1) - the same GlobalVariable name is redeclared locally here and would need updating by hand if that convention ever changes upstream. Notes and limitations - The demo strategy is a plain SMA crossover included to give the gate and audit plumbing something real to log against - review and validate before trusting it with a funded account. - Daily-loss and drawdown percentages are computed against equity read at the moment of each check, not against a broker-side "protection" value some funded-account platforms compute server-side; treat this as an independent client-side safety net, not a replacement for the firm's own enforcement. - The trading day rolls over at broker-server midnight, read from TimeCurrent() - if the firm's rules use a different reference timezone for "daily" resets, adjust RollTradingDayIfNeeded() accordingly. - InpObeyKillSwitch only reads the KILLSWITCH_ACTIVE GlobalVariable - it provides no way to trip the switch itself; pair it with a Script, panel, or this catalogue's KillSwitchProtocol Library / KillSwitchListener EA on the tripping side. - The audit CSV accumulates for as long as the file exists; nothing here rotates or archives it automatically - a long-running funded account should periodically move the file out of MQL4\Files\ (or MQL5\Files\ on the native MQL5 build) for record-keeping.

Expert advisor · MT5 · v1.0 · Free

About Compliance Ready Template

Compliance Ready Template is an expert advisor (trading robot) for MetaTrader 5 based on Moving Average. It trades only in the hours you set (time filter) and can size trades from your balance and risk percent. It has 15 settings, such as Fast ma period, Slow ma period and Risk percent. MQL source code included.

Files in the download: ComplianceReadyTemplate.ex5, ComplianceReadyTemplate.mq5, ComplianceReadyTemplate.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Fast ma period10Fast MA period for the demo signal
Slow ma period30Slow MA period for the demo signal
Risk percent0.5Risk per trade, percent of equity
Stop loss pips25Stop-loss distance in pips
Take profit pips50Take-profit distance in pips
Magic number49800Magic number for this instance's positions
Daily loss limit pct4.0Block new trades once today's loss exceeds this % of the day's starting equity
Max drawdown pct8.0Block new trades once overall drawdown from peak equity exceeds this %
Max trades per day6Block new trades once this many have opened since the trading-day rollover
Max open positions1Block new trades if this many are already open for this magic
Max lot size1.0Hard cap on any single order's lot size, regardless of risk sizing
Trading start hour0Trading window start, broker time, 0-23 (set equal to End to disable the window)
Trading end hour24Trading window end, broker time, 1-24 (24 = midnight, i.e. open all day)
Audit log nameComplianceReadyTemplate_audit.csvAppend-only audit trail, in MQL5\Files\
Obey kill switchtrueIf true, refuses to trade while KILLSWITCH_ACTIVE is set

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Buy/Sell Arrows · Risk & Lot Size · Time Filter · Moving Average · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria