Watch how to download trading robots for free
Find us on Facebook!
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

Prop Firm Guardian - daily loss, max loss and profit target lock - expert for MetaTrader 5

Augusto Martin D'anna
Augusto Martin D'anna
MQL5 & Pine Script developer | Trader since 2019 | Strategy validation
As a trader, I know a bot is only as good as the logic behind it. I bridge
trading concepts and clean code: I don't just follow instructions, I make
sure your EA behaves exactly the way your strategy intends.
Views:
67
Rating:
(1)
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Prop Firm Guardian is a risk utility for funded and challenge accounts (FTMO-style rules). It does not open any trades. Attach it to one chart and it watches the equity of the whole account on every tick and once per second, closing everything before a prop firm limit is broken.

How the limits act

How it works

  • Daily loss: when equity falls to the daily floor, it closes all positions and pending orders and blocks trading until the next day. The floor is the balance at the day start minus the daily limit, measured as a % of the initial balance (FTMO style) or of the day-start balance.
  • Max loss: when equity falls to the max loss floor, it closes everything and blocks trading permanently (until you reset it). The floor can be static (from the initial balance) or trailing (from the highest closed balance).
  • Profit target (optional): when equity reaches the target, it closes everything and locks the account, so a passed challenge is not given back.
  • Safety buffer: acts a few tenths of a percent before the real limit, to leave room for slippage and spread.

While blocked, any new position (manual or from other EAs) is closed immediately, and the terminal global variable PFG_BLOCKED is set (1 = until next day, 2 = permanent), so your own EAs can check it before trading. The day-start balance is rebuilt from the deal history, so the daily floor is correct even if the terminal was off at the reset time. Deposits and withdrawals are not counted as trading P/L.

Inputs

  • Initial account balance - the starting balance of the challenge/funded account.
  • Daily loss limit, % and Daily limit measured as - % of the initial balance or of the day-start balance.
  • Max loss limit, % and Max loss mode - static or trailing.
  • Profit target, % - 0 disables it.
  • Safety buffer - act this % before the limit (default 0.5).
  • Day reset hour - server hour when the trading day starts.
  • Also close manual trades - if false, only trades with a magic number are closed.
  • Show status on the chart - equity, both floors and the room left.

Notes

  • Works on any symbol and timeframe; the chart it is attached to does not matter.
  • Closing is done at market, so in fast markets the final equity can be slightly below the floor. Keep a buffer.
  • To remove a permanent block, delete the global variable PFG_BLOCKED (F3 in the terminal). It is reset automatically when you log into a different account.
  • Tested in the Strategy Tester with a harness that opens random trades: daily blocks, the max loss block and the target lock all triggered before the real limits, and no position stayed open while blocked.
  • Always check your own prop firm's exact rules: this tool helps, but it does not replace reading them.
Trade Permission Checker - finds why an EA or copier cannot trade Trade Permission Checker - finds why an EA or copier cannot trade

Finds out why an EA or trade copier cannot trade on your account. Read-only script, never trades.

Opening Range Breakout Box Opening Range Breakout Box

Opening range breakout indicator for MT5 on Gold (XAUUSD), forex and indices: box of the first minutes of up to three sessions, breakout levels, two targets by range height, arrows and alerts on the closed candle. Open source code.

Simple License - lock your EA to accounts, expiry date, demo-only or server Simple License - lock your EA to accounts, expiry date, demo-only or server

Minimal include file to license your own EAs and indicators: allowed account numbers, expiry date, demo-only trial mode and broker server filter. Example EA included.

Equity Target Closer - close all trades at a profit or loss level Equity Target Closer - close all trades at a profit or loss level

Closes all positions and pending orders when the account profit or loss reaches your target, in money or % of balance. Floating or full-day P/L, symbol and magic filters.