StopFirst Account Guard
- Yardımcı programlar
-
RUSLAN SLOBODIANIUK
Знание языков и технологий:C
C++
Visual C++
WinAPI
C#
GDI+
ADO.NET
LINQ to SQL
WPF
WCF
SQL
XHTML
XML
PHP
MySQL
JScript
Unity3D(C# scripting) - Sürüm: 1.1
- Güncellendi: 21 Ekim 2026
- Etkinleştirmeler: 10
StopFirst Account Guard watches your whole account and enforces the loss limits you set: a daily loss limit, a maximum overall loss, and if you want, a profit target and time rules. When a limit is reached it closes every position on the account, deletes every pending order, and keeps the account flat until the limit resets.
It is built for prop-firm challenges and funded accounts, where one breach of the daily or overall limit ends the account and the rules are measured to the cent on equity, floating loss included. It works just as well as a hard daily stop on your own account.
WHAT IT CANNOT DO - PLEASE READ
- It reacts; it cannot prevent. No program in MetaTrader can stop you or another EA from sending an order. "Locked" means: anything opened is closed again at once.
- It acts only while this terminal runs and is connected. Trades from your phone or another terminal on the same account are closed only if this terminal is running. For a challenge, run it on a VPS.
- It closes at market. In a fast market closing several positions slips, so the guard acts before the limit, not at it - at 95 % of the limit by default.
- It does not know your firm's rules. You type them in. Below are the questions to ask your firm.
HOW TO USE IT
1. Attach it to any one chart and allow Algo Trading. It watches the whole account from there - every symbol, every EA, manual trades included.
2. Set the account size your firm's percentages refer to (100000 for a 100k challenge), the daily and overall limits, and when the firm's day resets.
3. Leave it running. The panel shows how much of each limit is used and how much room is left.
THE RULES
Daily loss limit (on by default, 4 %)
- In percent of the account size, or in money.
- Measured from the day-start balance (default), the higher of day-start balance and equity, or the day-start equity - the three ways firms define it.
- Floating loss included (default), or closed trades only. With closed trades only, an open position can run far past the limit before it closes - the guard acts on what has been closed. Use it only if your firm measures that way.
- The day resets at an hour you choose in the broker's time, GMT, Central European time or New York time, each with its own daylight saving dates. Default: midnight Central European time. Most protectors reset at the broker's midnight and are an hour off for part of the year.
Maximum overall loss (on by default, 8 %)
- Static: the floor is the account size minus the limit (default).
- Trailing the equity high, or trailing the closed-balance high, optionally stopping once the floor reaches the account size.
- The floor is shown as a number, the way firms show it in their dashboards.
Profit target (off by default)
- When equity reaches the target: close everything and lock, so a passed challenge is not given back before the day ends.
Buffer and warnings
- The guard acts at 95 % of each limit (adjustable, 50-100 %).
- At 70 % (adjustable) it warns: panel colour, an alert, and a push notification to your phone if MetaTrader is set up for it.
Time rules (each off by default)
- Close everything before the weekend: Friday at a time you set, on the same clock as the daily reset.
- Close positions before high-impact news: a number of minutes before an event in the currencies of your open positions, or of a list you give.
- No new positions outside hours: a position opened outside a GMT window you set is closed at once. Positions you already held when the guard was first attached are left alone.
These are reactions too - "no new positions" means a new position is closed immediately.
WHAT HAPPENS AT A BREACH
1. Every position on the account is closed - every symbol, every magic number, manual trades included - largest loss first, so the positions doing the damage go before the others.
2. Every pending order is deleted.
3. The account is locked:
- after a daily breach, until the next daily reset;
- after an overall breach or the profit target, until you clear the lock.
4. While locked, any new position or pending order - from any EA, from your phone, by hand - is closed or deleted again within a second. The journal records it once a minute.
The lock is stored on disk the moment it starts. Restarting the terminal or re-attaching the EA does not clear it.
Clearing a lock takes two clicks on the panel. A daily lock cannot be cleared early - that is the point of a daily stop - and an overall lock cannot be cleared while the loss is still past the limit. After a profit-target lock is cleared, the target fires again only once equity has been back under it.
Time rules close only what they concern and never lock.
NUMBERS YOU CAN TRUST
- Equity is measured four times a second, not only on ticks: a loss on another symbol does not wait for the next tick on the chart symbol.
- Deposits and withdrawals are not profit or loss. They are read from the deal history and move the limits' reference points; a withdrawal does not look like a 5 % loss, and a deposit does not hide one.
- If the terminal was off when the day reset, the day-start balance is rebuilt from the deal history - not taken as "the balance now", which would silently give you a fresh daily allowance after a losing morning and a restart.
- Nothing is measured until the terminal has synchronised with the server: until the deal history adds up to the balance to the cent. A guard that measures the moment it starts can see a balance of almost zero and close the account.
IT WARNS YOU BEFORE THE BREACH
The panel compares what your open positions stand to lose if every stop is hit - from the current price - with the room left today:
if all stops hit -3 140.00 OVER ROOM
Your stops alone could breach the daily limit: you see it while there is still time to act. A position without a stop cannot be measured at all; it is shown in red as UNBOUNDED, and the panel shows WARNING.
THE PANEL
One word at the top, readable from across the room: ACTIVE, WARNING, LOCKED, CANNOT CLOSE or NO CONNECTION.
DAILY LOSS - used, in money and percent, with a bar to the point where the guard acts; room left and when the day resets; what the loss is measured from and where the day-start figure came from; the risk if all stops hit.
OVERALL LOSS - equity, loss, room, the equity at which the guard closes everything, the high for trailing modes.
PROFIT TARGET - the equity it fires at and how far away it is.
TIME RULES - what is set, and the event closing positions right now, if any.
Open positions and pending orders on the account, and the last action and its result. Each section can be collapsed and the whole panel minimised.
Two buttons, each acting on the second click within three seconds: "close all now" - your own flatten, without a lock - and, while an overall or target lock is in force, "clear lock".
IT NEVER SHOWS "OK" ON A GUESS
- Not connected: NO CONNECTION - limits not watched.
- Algo Trading off, or trading not allowed on the account: CANNOT CLOSE, in red, with an alert. Limits are still measured and a breach still locks; closing starts the moment it can.
- Broker GMT offset not measurable: the day resets by the broker's clock, and the panel says so. You can set the offset in the inputs.
- Day start rebuilt from history, or equity at the day start unknown: labelled on the panel.
- Economic calendar not loaded: the news rule says "calendar unavailable" and closes nothing on a guess.
QUESTIONS TO ASK YOUR FIRM
- Is the daily loss measured from the day-start balance, the day-start equity, or the higher of the two?
- Does it include floating loss?
- When does the day reset, and in which time zone?
- Is the maximum loss static, or does it trail? Trailing equity or closed balance? Does it stop trailing at the starting balance?
- Is there a profit target, and do you want to stop trading when you reach it?
STRATEGY TESTER
A guard that only watches shows nothing in a backtest, so in the Strategy Tester it opens demonstration trades: pairs sized so that a move of half an average day against them reaches the point where the guard acts. Good days end at the target; bad days show the warning, the breach, the close, the lock and its end at the next day. Under each lock one more trade is opened "as another program would", to show it closed again. Demonstration trades never happen outside the tester. On a deposit too small to carry the margin of one minimum lot it opens none, and logs no error. A longer backtest usually ends in an overall-loss lock: the demonstration loses on purpose, and after that the account stays flat, as it should.
In the tester:
- Set the broker's GMT offset in the inputs to reset the day in your firm's time zone; the tester cannot measure it, and the day otherwise resets by the broker's clock, which the journal says.
- There is no economic calendar, so the news rule is inactive and says so.
- Alerts and push notifications are ignored by the tester.
INPUTS
Account
- Account size the limits refer to (0 = the balance when the guard is first attached; setting it is recommended).
Daily loss limit
- On or off; percent or money; value (default 4 %); measured from; floating included; time zone and hour of the reset (default 00:00 Central European time).
Maximum overall loss
- On or off; percent or money; value (default 8 %); static or trailing; trailing stops at the account size.
Profit target
- On or off; percent or money; value.
Safety
- Act at this share of each limit (default 95 %); warn at this share (default 70 %); push notifications.
Time rules
- Friday close and its time; news close, importance, minutes before, currencies; no positions outside a GMT window; the broker's GMT offset (99 = measure it).
Strategy Tester
- Demonstration trades on or off, bars between them, their magic number; a withdrawal check used for testing.
Automation
- Accept panel commands from another program on the same chart. Off by default; used for automated testing.
Appearance
- Panel position, font size, colours.
Every input is checked when the EA starts. A wrong value stops it with a message saying which one and why.
TOGETHER WITH STOPFIRST TRADE MANAGER
On the same terminal, StopFirst Trade Manager (1.20 and later) reads what the guard publishes. While the account is locked it refuses an entry before sending it, instead of opening a trade the guard would close a second later. And it refuses a trade whose stop, together with the stops already open, could reach the point where the guard acts - the panel shows both figures.
The guard publishes its state - running, locked, the room left, the risk if every stop is hit - in terminal global variables: no DLL, no internet. Any EA on the same terminal can read them. Whatever is opened under a lock is still closed.
GOOD TO KNOW
- Attach it to one chart only. Two guards on one account would both close everything - harmless, but pointless.
- It never modifies a position - no stop added, no stop moved. It only closes.
- Its state is kept in terminal global variables named after the account number, so two accounts on one terminal stay apart. They are written to disk after every change.
- The equity high while the terminal was off cannot be known. Trailing modes use the stored high and the closed-balance high from the deal history, whichever is larger.
- Removing the EA leaves the account unguarded. The journal says so.
- It is an Expert Advisor, so it takes the chart's EA slot. Use a chart your own EA does not run on.
- No DLLs, no internet access, nothing sent anywhere. Push notifications go through MetaTrader's own channel.
QUESTIONS
Will it close my manual trades and other EAs' trades?
Yes - at a breach, under a lock, and when a time rule applies. That is its purpose. It never modifies them.
What if the terminal is closed when the limit is reached?
Nothing happens until it runs again: no program can act while MetaTrader is closed. Use a VPS for a challenge.
Can it stop me from opening a trade?
No program in MetaTrader can. Under a lock, a new trade is closed again within a second.
Why does it act at 3.8 % when my limit is 4 %?
That is the buffer. Closing several positions at market slips; acting at 95 % of the limit leaves room for it. You can set it to 100 %, and the journal will warn you.
I withdrew money. Will it count as a loss?
No. Deposits and withdrawals are read from the deal history and excluded.
Does it work with StopFirst Trade Manager?
Yes, on separate charts, and from Trade Manager 1.20 they work together: the Trade Manager refuses entries while the guard has locked the account, and entries whose stop could reach the limit. The guard still closes everything when it must, the Trade Manager's trades included.
