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

Prop Risk Guard - daily loss and drawdown protection - expert for MetaTrader 5

Views:
70
Rating:
(1)
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Prop Risk Guard watches the whole account (or one symbol or magic number) and acts as soon as a risk limit is reached. It closes all positions, deletes pending orders and then closes any new trade until the lock resets. It works with any Expert Advisor and with manual trading.

Daily loss limit reached: everything closed, account locked until the next day

How it works

Daily loss limit: today's closed plus floating profit/loss of the protected trades is compared with the day's starting balance, equity or the higher of the two. The day starts at the server hour you choose, so it can match your prop firm's rules.

Max drawdown: equity is compared with the starting balance (static) or with the highest equity reached (trailing). Profit target (optional): when it is reached, everything is closed and the account is locked to keep the profit.

A warning alert is sent when a set share of a limit is used. A safety buffer can make the guard act a little before the real limit, because fast markets can move between two checks. The daily lock resets at the next day start; the drawdown and target locks stay on until you enter a new starting balance. The state is kept in terminal global variables, so it survives a terminal or VPS restart.

Inputs

Daily loss limit: on/off, given as percent or money, the limit value, measured from the day's starting balance, equity or the higher of the two, and the server hour when the day starts.

Max drawdown: on/off, percent or money, the limit value, static or trailing, and the account starting balance (0 = the balance when the EA is attached).

Profit target: on/off, percent or money, and the target value. Protection: protect the whole account, this chart's symbol or one magic number; warning level in % of a limit; safety buffer in %; maximum slippage when closing.

Panel and alerts: show the panel, its corner and offsets, popup alerts and push notifications. Strategy Tester: demo mode opens random, deliberately risky trades (tester only) so you can watch the guard warn, close everything and lock.

Usage

Attach the EA to one chart of any symbol and timeframe, and keep Algo Trading enabled so it is allowed to close trades. Run it on a VPS so the account is protected all the time. The guard never opens trades on a real account. In a very fast market or on a price gap the final loss can be a little larger than the limit, so use the safety buffer to leave room.

Repaint Checker - find out whether an indicator repaints Repaint Checker - find out whether an indicator repaints

Tests any MT5 indicator for repainting: records what every buffer showed when each bar closed, reads the same bars again later and reports values that changed, signals that appeared late and signals that vanished, with dates.

Supertrend Gold Signals Supertrend Gold Signals

Supertrend indicator for MT5 on Gold (XAUUSD), forex and indices: ATR trailing line in two colours, buy and sell arrows only on the closed candle of the flip, popup, push and sound alerts. Open source code.

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.