Failsafe Prop Firm Daily Loss and Target Lock
- Utilità
- Versione: 1.3
- Attivazioni: 10
Failsafe watches the rules that can end a prop firm account: the loss of the day, the total loss and, if you wish, the profit target of your phase. It works at the level of the whole account. When a threshold is reached, it closes every position, deletes pending orders and keeps the account flat until the next daily reset.
It is a utility, not a trading robot. It never opens a trade on your account.
What it does
- Daily loss rule. The reference is the balance at the daily reset, rebuilt from the account history, so it stays correct after a restart of the terminal. The loss is measured on equity or on balance. Two warnings come before the threshold, at 50 % and 75 % by default.
- Total loss rule (optional). The same action when equity falls to a level counted from the initial account size.
- Profit target lock (optional). When the target of the phase is reached, the tool closes everything, checks that the balance is at or above the target, and keeps the account flat until you remove the lock. A minimum number of trading days can be required.
- Block until the reset. After a stop, any new position or pending order is closed again, whether it comes from you, from another Expert Advisor or from a mobile terminal.
- The terminal can be closed after a stop (optional), so that other programs stop sending orders.
Daily reset
Presets: 00:00 Central European time, 00:00 trade server time, 17:00 New York time, 00:00 UTC, or a custom time and time zone. Daylight saving time is handled for Europe and New York. The default preset is the rule used for example by FTMO: reset at midnight Central European time, loss measured on equity. The threshold is a percentage of the initial account size or of the daily reference.
Safe to try
- Simulation is the default mode. The tool writes what it would do and sends the alerts, but closes nothing. You arm it once you have seen it work.
- After each connection it waits until the account is synchronized before it acts.
- If the balance does not match the initial account size, it takes no action and warns you.
- The initial account size is read from the account history. You can also enter it.
Alerts and panel
Alert window, push notification, e-mail and an optional web address of your own. The panel shows the state, the time left before the reset, the reference, the loss of the day, the distance to the stop and the progress to the target. A status line is written to the journal every hour.
In the Strategy Tester
The tool opens random sample trades so that you can watch it work: warnings, stop, block and reset. These trades are not a strategy. They are never opened on an account.
Please note
- The tool runs inside your terminal. It can act only while the terminal is running, connected, and Algo Trading is switched on.
- Positions are closed at market. In a fast market or after a price gap, the final loss can be larger than your threshold. Set the threshold below the limit of your firm. The default is 3.5 %.
- Hedging and netting accounts, any symbol. Attach it to one chart per account.
- It does not replace a stop loss and it does not improve a strategy. Check the current rules of your own firm before you set it.
Quick start
- Attach Failsafe to one chart of the account you want to protect. Any symbol and any timeframe will do. One copy watches the whole account.
- Keep "Simulation" on at first. Read the first lines in the Experts tab: mode, daily loss threshold, daily reset and reference. The initial account size is read about 10 seconds after the connection.
- Choose the daily reset of your firm and set the threshold below the limit of your firm.
- Let it run. In simulation, when the threshold is reached, the tool writes "SIMULATION: would have closed everything" and sends the alerts, once per day. Nothing is closed.
- To arm it, set "Simulation" to false. Check that Algo Trading is on in the terminal and allowed in the properties of the tool. The first line in the Experts tab must read "ARMED (closes for real)".
What happens at a stop
The tool closes every position at market, deletes every pending order, writes a stop file and sends the alert. Until the next daily reset, any new position or pending order is closed again. If an order is refused, the tool tries again every 10 seconds, then every 60 seconds after three refused attempts. A position on a closed market is closed when the market reopens. A position larger than the maximum order volume is closed in several orders.
How to lift a block
After a daily stop, the block ends by itself at the next daily reset. To end it earlier, delete the stop file of the day in MQL5\Files\Failsafe. The tool sees it within 10 seconds. If the loss of the day is still at the threshold, the tool stops again at once: raise the threshold first.
After a profit target lock, the block does not end by itself. Delete the target file in MQL5\Files\Failsafe.
Closing the terminal
With this option, once everything is closed, the tool closes the terminal. If the terminal is started again while the block is active, the tool closes it again 60 seconds after the connection. To stop this, delete the stop or target file while the terminal is closed, or within these 60 seconds. The terminal is never closed in the Strategy Tester.
Settings
Mode
- Simulation: journal and alerts only, nothing is closed. Default: true.
Account
- Initial account size (0 = detect from the first deposit). The size your firm uses for its percentages. With 0, the tool adds up the deposits made before the first trade. If the history shows no deposit, it uses the current balance and says so in the journal: enter the size yourself in that case. If the balance is below 50 % or above 200 % of this size, the tool takes no action and warns you.
Daily loss rule
- Guard threshold: loss of the day, % (0 = off). Default: 3.5.
- Daily reset. 00:00 Central European time (default), 00:00 trade server time, 17:00 New York time, 00:00 UTC, or custom time.
- Daily reference. Balance at the daily reset (default), or the higher of balance and equity at the daily reset. The equity at the reset is known only if the tool was running at that moment. Otherwise the balance at the reset is used and the journal says so. Deposits and withdrawals are not counted as trading.
- The threshold is a: % of the initial account size (default), or % of the daily reference.
- The loss is measured on: equity, open positions included (default), or balance, closed trades only.
- First alert and second alert at this % of the threshold. Defaults: 50 and 75. 0 = off. Each warning is sent once per day.
Custom reset time (only when Daily reset = Custom)
- Time zone of the reset: fixed UTC offset, Central Europe, New York or trade server time.
- UTC offset in hours, reset hour, reset minute.
Total loss rule (optional)
- Guard threshold: loss from the initial size, % (0 = off). Example: with 9, the tool stops everything when equity falls to 91 % of the initial account size. While equity stays below this level, the stop comes back after each daily reset.
Profit target lock (optional)
- Profit target of the phase, % of the initial size (0 = off).
- Minimum trading days before the lock (0 = none). A trading day is a day, counted from the daily reset, on which at least one position was opened.
- Open positions: buffer above the target, % of the initial size (default 0.03), and extra buffer, basis points of the open exposure (default 4). With open positions, the tool acts when equity is above the target plus these two buffers. They cover the cost of closing.
- Consecutive checks above the target before acting. Default: 3.
- After closing, the tool checks the balance. If it is at or above the target, the target file is written and the account stays blocked until you delete this file. If it is below the target, there is no lock, trading goes on and you receive an alert.
- The lock needs 60 seconds of connection. If a market is closed, the tool waits until it reopens.
Actions
- Close the terminal after a stop or a lock. Default: false. Read "Closing the terminal" first.
- Check period, seconds. Default: 2. From 1 to 60.
- Magic number of the closing orders.
Alerts
- Alert window in the terminal. Default: true.
- Push notification to the mobile terminal. Set your MetaQuotes ID in Tools > Options > Notifications.
- E-mail. Uses the mail settings of the terminal in Tools > Options > Email.
- Web address called on each alert (optional). The alert text is sent as plain text to an address of your own. Add this address in Tools > Options > Expert Advisors > Allow WebRequest for listed URL.
- Status line in the journal every N minutes. Default: 60. 0 = never.
Panel
- Show the panel on the chart, distance from the left edge, distance from the top edge.
Strategy Tester only
- Open sample trades to show the guard at work, and exposure of a sample trade as a multiple of the balance. These two settings have no effect on an account.
Files written in MQL5\Files\Failsafe
- stop_[account]_[day].txt: written at a stop. While it exists, the account stays blocked until the next daily reset.
- target_[account]_[day].txt: written when the profit target is locked. While it exists, the account stays blocked.
- simulation_[account]_[day].txt and simulation_target_[account]_[day].txt: what the tool would have done in simulation.
- info_target_[account]_[day]_balance.txt and info_target_[account]_[day]_days.txt: target reached but not locked, with the reason.
- status_[account].txt: the last status line.
Questions and answers
Does the tool open trades?
No. On an account it only closes positions and deletes pending orders. In the Strategy Tester it opens random sample trades, so that the guard has something to close.
Does it close trades opened by hand, by another Expert Advisor or from a phone?
Yes. It watches the whole account, all symbols, whatever opened the trade.
Another Expert Advisor keeps opening trades after the stop. What happens?
Each new trade is closed again within about 10 seconds, and each one costs the spread and the commission. Use the option that closes the terminal, or stop that Expert Advisor.
Can the loss be larger than my threshold?
Yes. The tool checks the account every 2 seconds and closes at market. Slippage and price gaps are not under its control. Keep a margin between your threshold and the limit of your firm.
What happens if the terminal is closed or loses the connection?
The tool cannot act while the terminal is off or disconnected. At the next start it rebuilds the reference of the day from the account history, reads the stop and target files, and acts if a threshold is reached.
What happens when the market is closed?
Positions on an open market are closed at once. Positions on a closed market are closed when it reopens.
The journal says "orders are NOT allowed". What should I do?
Switch Algo Trading on in the terminal and allow algo trading in the properties of the tool. An account opened with an investor password cannot trade.
The panel says "CHECK THE INITIAL ACCOUNT SIZE". Why?
The balance is below 50 % or above 200 % of the initial account size. The tool takes no action until the setting "Initial account size" is corrected.
Which accounts are supported?
Hedging and netting accounts, in any deposit currency. The reset presets cover the usual daily rules of prop firms. Always check the current rules of your own firm.
Why is the default threshold 3.5 %?
It leaves a margin below a 5 % daily limit. Set the value that fits the limit of your firm.
