A risk manager advisor for MT4: calculation and limit utilities
A risk manager advisor for mt4 closes two gaps the terminal leaves to the trader: converting the risk percentage into lots and stopping trading after the daily limit of losses. Both tasks are solved by code that lives inside the terminal and works while the terminal is open. We take apart which programs of this class exist, what exactly they do with your account and which checks are mandatory before someone else's code gets access to your orders.
Programs inside MetaTrader are an add-on: they do not replace the terminal but add to it what it does not have. Size calculation for a percentage, an automatic stop together with the entry, a hard ceiling on the loss for the day and a ban on trading after a streak of stops.
Four types of program inside the terminal
Four different entities live in MetaTrader, and confusing them is expensive: they have different rights and different behaviour on a restart. A loss limiter written as a script will not protect the account — a script runs once and exits.
Runs once on launch and finishes. Suitable for one-off actions: placing stops on all open positions, closing everything at market, moving stops to break-even.
a one-off actionDraws an interface on the chart and computes values, but may have no trading rights. It shows the size for your percentage and the price of the stop in money, while you send the order yourself.
calculation and promptingRuns constantly on the chart and can send orders. It opens a position with the calculated size, immediately places the stop and the take and runs a trailing stop by a set rule.
execution on commandIt opens nothing, it only forbids. It watches the equity and the number of trades, closes positions and blocks trading when the daily loss limit is reached.
prohibition and protectionThe first three save time and reduce the chance of an arithmetic error. The fourth type saves the account: it is the only one that intervenes at the moment when the trader is no longer reasoning soberly.
Trade Assistant MT4 and size calculation panels
Utilities of the trade assistant mt4 class are all built the same way: a panel on the chart, a field for the risk percentage, a field for the stop level and a button to send the order. The value is not in the button but in the fact that the size is recalculated at every shift of the stop — and people stop doing it by hand.
| Panel field | What the trader sets | What the program calculates |
|---|---|---|
| Risk | a percentage of funds or an amount | the risk in the account currency |
| Stop-loss | the price of the level or the distance | the distance in pips |
| Size | nothing | lots for the risk and the stop, rounded down |
| Take-profit | a price or a multiple of the risk | the target at the set ratio |
| Margin | nothing | the collateral for the calculated size |
| Spread | nothing | a correction to the actual entry price |
Such a panel has to be checked once and on a demo: open a trade with the minimum size, wait for the stop to trigger and compare the actual loss with the declared risk. A discrepancy of more than a tenth of a percent means the program counts from the balance instead of equity or does not account for the spread.
Risk manager ea mt5: a loss limiter advisor
A limiter is the most useful and the most underrated program of the class. It does not improve the entry and does not increase the profit: it turns a soft rule into a hard one, taking the decision away from the trader at the moment when they are in no state to decide.
trading stops: equity ≤ equity at the start of the day × (1 − the limit)
| Restriction | How it is set | What it does when it fires |
|---|---|---|
| The daily loss limit | a percentage or an amount | closes the positions, cancels the pending orders, blocks new ones |
| A loss limit for the week | a percentage of Monday's equity | the same over several days |
| A streak of stops in a row | a number of trades | a pause until the end of the day |
| A maximum number of trades | per day | a ban on opening beyond the limit |
| A maximum total size | lots | does not let the position be built up |
| A ban on trading by time | hours and news | blocking in the set intervals |
A practical nuance: the limit has to be counted from equity rather than from the balance, and the reference point has to be fixed at the start of the day. Otherwise, after a losing streak the limit is recalculated from the shrunken account and allows you to lose again and again — a little less in money each time, but just as much in percent.
What to check before installing someone else's advisor
Any expert advisor is someone else's code with access to your orders. The five checks below take one evening and separate a useful utility from a nuisance.
The same broker, the same account type, the same symbols. A demo differs from a live account in execution, but it shows the program's logic in full.
the first eveningOpen a trade and compare the calculated volume with the formula. A match down to the volume step is the only proof that the program counts correctly.
the first eveningClose and reopen the terminal: the limiter has to remember the day's reference point instead of starting the limit over.
compulsoryThe program works only while the terminal is running. If the protection has to be permanent, the terminal is kept on a server rather than on a home computer.
before going liveAlgorithmic trading is enabled selectively, and the trading password to the account is never handed to anyone.
continuouslyWhy advisors are dangerous
Complaints about programs of this class almost always come down to four situations. None of them has anything to do with an error in the volume formula.
Advisors and utilities: short answers
- Do you need an advisor if you calculate the volume yourself
- Not necessarily. A utility saves seconds and removes input errors, but it runs the same formula. A loss limiter is more useful: it does what a person in drawdown does badly.
- Where to get these programs
- The terminal's built-in market, the developer's own site, or your own code. Market products usually come with a demo version for the tester.
- Do advisors work in the mobile terminal
- No. Mobile versions of MetaTrader do not execute program code: utilities and limiters live only on a computer or a server.
- Can you write such programs yourself
- Yes, the MQL language was made for it. A daily limit guard is a typical first program: a few dozen lines and straightforward logic.
- Can an advisor be checked in the strategy tester
- The entry and management logic — yes. The limiter's behaviour at the boundary of the day and on a terminal restart is not reproduced by the tester.
- What to do when the volume does not match
- Compare three things: the calculation base, the pip value and the rounding rule. The error is almost always in one of those three places.
Frequently asked questions
How an expert advisor differs from a script in MetaTrader
A script runs once and finishes, an advisor works continuously as long as it is on the chart and the terminal is running. A loss limiter is possible only as an advisor: it has to watch the account without a break.
How a limiter advisor counts the daily limit
It remembers equity at the start of the trading day and compares the current value with it. When the drop reaches the set percentage, positions are closed, pending orders are removed and new trades are blocked until the next day.
Why the limit is counted from equity and not from the balance
The balance does not see floating loss: an open position in the red will not change it until it is closed. A limiter tied to the balance fires too late.
Is it safe to buy an advisor in the terminal's market
Buying is safer than downloading a file from the side: the product is tied to the account and comes with a demo version for the tester. But the code stays closed, so checking the behaviour on a demo is still needed.
Can a lot-size utility be wrong
It can, and there are three typical reasons: counting from the balance instead of equity, a wrong pip value on cross pairs, and rounding up. Each of them gives more risk than was planned.
Do you need a VPS for a limiter advisor
If the protection has to work at all times — yes. The utility does nothing while the terminal is off, and that is exactly when an open position goes against you.
Does a trailing stop in an advisor replace manual management
It makes management mechanical and identical every time, which is usually better than doing it by hand. But the rule for moving the stop is set by you, and a bad rule is executed by the advisor just as precisely as a good one.
Can several advisors be placed on one chart
On one chart — no, MetaTrader runs one advisor per window. A limiter is usually attached to a separate chart, because it is not tied to a specific symbol.
How to tell that an advisor increases volume after a loss
Check it in the tester: if after a losing trade the next volume is larger than the previous one at the same distance to the stop, it is a martingale, whatever the description calls it.
What to do if the advisor has stopped opening trades
Check that algorithmic trading is allowed, that the licence is still valid, that the symbol matches, and whether the program's own limit has fired. After firing, a limiter stays silent on purpose.
Is it worth trusting an advisor with the choice of an entry
That is no longer risk management but a trading system, and it has to be judged by statistics over the distance rather than by its description. Such an advisor has nothing to do with managing risk.
How many programs make sense at the same time
Usually two: a volume calculation panel and a loss limiter. Every further one adds a point of failure and reduces your understanding of what is happening to the account.