Watch how to download trading robots for free
Find us on Twitter!
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 Guard - expert for MetaTrader 5

Hayk Babayan
Hayk Babayan
Algorithmic trader. I build and test Expert Advisors for MetaTrader 5 with one rule: a strategy has to prove itself on data it has never seen before I trust it.
Views:
43
Rating:
(1)
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Most funded accounts are not lost to a bad strategy but to one bad day. Prop Firm Guard watches the account equity every second and acts before the firm's limit is reached, not after it. It never opens trades, so it can run next to any Expert Advisor or next to manual trading.

Prop Firm Guard: daily guard, maximum guard and lock

What it does

  • Daily loss guard. When equity falls to the daily limit minus a safety buffer, it closes all positions, deletes pending orders and keeps the account flat until the firm's next trading day.
  • Maximum loss guard. Static (initial balance minus the limit) or trailing (highest balance minus the limit; the trailing level stops at the initial balance). When it is hit, the account stays flat until you clear the lock.
  • Profit-target lock (optional). Closes everything and stops once the target is reached.
  • While a lock is active, trades opened later by other Expert Advisors or by hand are closed as well.
  • The firm's day can reset at any UTC hour; the broker's server offset is detected automatically.
  • Locks survive a terminal restart (they are kept in terminal global variables).
  • Optional filters: one magic number only, and/or this chart's symbol only.
  • Terminal alert and push notification to the MetaTrader mobile app.

Inputs

Initial account size 0 = read the first deposit from the account history
Daily loss limit, % 0 = off. Measured from the initial balance (most firms) or from the balance at the start of the day
Maximum loss limit, % 0 = off. Static or trailing
Buffer, % The guard acts this many percent before a limit, to leave room for slippage (0.5% is a sensible start)
Profit lock, % 0 = off
Firm's daily reset, UTC hour The hour at which your firm starts a new trading day
Magic number / this symbol only -1 = all trades including manual ones
Alerts, push, panel Notifications and the status text on the chart
Clear saved locks Set to true once after an account reset, then back to false

How to use

Attach it to ONE chart of the account (any symbol, any timeframe), keep Algo Trading on and enter the limits exactly as your firm states them. Check how your firm measures the daily limit: some use the initial balance, some use the balance or equity at the start of the day. The status line on the chart shows the current guard levels and the room left to each of them.

A guard reduces the damage of a bad day, but it cannot prevent slippage beyond the buffer when the price gaps (for example over a weekend or on major news). Always keep your own risk per trade sensible.

Missing Stop Loss and Take Profit Setter Missing Stop Loss and Take Profit Setter

Utility Expert Advisor that finds open positions without a stop loss or take profit and adds them at a fixed distance in pips from the open price. It never opens or closes trades.

Spread Spike Histogram with Moving Average Spread Spike Histogram with Moving Average

Separate window indicator that draws the spread of every bar as a histogram with its moving average and colors the bars where the spread is far above normal or above a fixed ceiling.

Risk Lot Calculator Risk Lot Calculator

Drop it on the chart at your stop-loss level and get the exact lot for your risk. Correct for gold, indices, crypto and cross pairs. It never opens trades.

Market Structure Visualizer - HH HL LH LL BOS CHoCH Market Structure Visualizer - HH HL LH LL BOS CHoCH

Free non-repainting MT5 market structure indicator that identifies confirmed HH, HL, LH and LL swings, plots BOS and CHoCH structure breaks, and includes close/wick confirmation, dashboard bias and optional alerts.