Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Experts

PropGuard - account risk manager for prop firm accounts - expert for MetaTrader 5

Sergej Michajlik
Sergej Michajlik
I build and maintain MT5 Expert Advisors, mostly for people trading index CFDs on prop firm accounts. DAX and S&P 500 are the markets I know best, I trade them myself on an FTMO account, so I know the rules from the trader side, not only from the code side.
Views:
20
Published:
PropGuard.mq5 (13.85 KB) view
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

PropGuard watches the whole account, not one chart. Attach one copy to any chart and it checks every position on the account, whatever EA or magic number opened it, and closes everything when a prop firm style limit is reached.

What it enforces: a daily loss limit on equity including floating profit, with a reset at a server time you set; a maximum loss measured either from the initial balance or trailing from the equity peak; a lot cap per position; an optional trading window; an optional Friday close; and an optional blackout around high impact news from the MT5 economic calendar. After a breach it flattens the account, cancels pending orders and keeps closing anything new until the next daily reset, so another EA cannot trade you into a second breach on the same day.

Everything it does is written to the Experts log, to a CSV file in MQL5\Files named after the account login, and optionally sent as a push notification.

Symbol and timeframe do not matter, the guard works on the account. It runs on a timer as well as on ticks, so it keeps checking during quiet markets.

Inputs:
InpInitialBalance, the account size the firm's rules refer to.
InpDailyLossPct and InpMaxLossPct, the guard's own limits in percent. Set them a little below the firm's, for example 4 and 8 on an account with 5 and 10 percent rules, so you stop before the firm stops you.
InpMaxLossMode, static from the initial balance or trailing from the equity peak.
InpResetHour and InpResetMinute, the daily reset in server time.
InpMaxLotsPerPos, any position larger than this is closed.
InpCloseOnBreach and InpBlockAfterBreach, flatten on a breach and keep the account flat until the next reset.
InpUseWindow with start and end hour, InpFridayClose with its hour, both in server time.
InpUseNewsFilter, InpNewsCurrencies, InpNewsMinutesBefore and After, the calendar blackout.
InpPushAlerts, push notification on every action.
InpMagicToIgnore, positions with this magic number are left alone.

Tested on an FTMO trial account.

log properties


NeonDesk - Neon Manual Trading Panel with Multi-Timeframe Bias NeonDesk - Neon Manual Trading Panel with Multi-Timeframe Bias

Draggable on-chart manual trading panel with multi-timeframe bias, ATR SL/TP hints, a trailing stop and one-click BUY/SELL/CLOSE ALL.

Price Action Volumetric Order Blocks MT5 Price Action Volumetric Order Blocks MT5

Open-source MT5 indicator for confirmed market structure, volumetric order blocks and estimated buy/sell activity.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.