RiskManager 2.2 for MT4: Complete User Manual
1. What RiskManager Does
RiskManager is an account-level protection Expert Advisor for MetaTrader 4. It watches account equity, daily and weekly results, individual trades, open-order counts, and same-direction grid exposure. When an enabled rule is breached, it can attempt to close monitored market orders, delete monitored pending orders, send notifications, close another chart, or close the terminal.
This utility does not choose entries, calculate lot size before an entry, or open new trades. It is an enforcement layer for limits that you configure. Use normal position sizing, Stop Loss orders, strategy controls, and broker-side safeguards as the first line of risk management.
Official product page: RiskManager for MetaTrader 4
The source-backed scope of version 2.2 includes:
- an absolute account-equity floor;
- daily and weekly loss limits in account currency;
- simple-result and trailing-equity limit modes;
- daily drawdown and profit percentage controls;
- daily profit, trade-count, losing-trade, and consecutive-loss controls;
- per-trade loss, profit, and percentage-loss controls;
- an open-order limit and an Anti Grid rule;
- optional inclusion of floating results, swaps, and commission;
- a Magic Number zero filter;
- chart information, push notifications, email, chart closure, and terminal closure.
RiskManager reacts after MetaTrader detects a breach. It does not guarantee that the final fill will equal the configured threshold. Gaps, slippage, a closed market, requotes, rejected requests, missing connectivity, terminal interruption, and broker restrictions can make the realized result worse than the trigger value. Leave a practical buffer below any external loss rule and test the complete workflow on a demo account.
2. Requirements and Installation
- Install RiskManager from the MQL5 Market in MetaTrader 4.
- Open one chart on the account that you want to protect.
- Drag RiskManager from Navigator > Expert Advisors onto that chart.
- In the Common tab, allow automated trading for the EA.
- Configure the Inputs described below.
- Enable AutoTrading in MetaTrader 4.
- Keep the terminal connected and keep the RiskManager chart open whenever protection is required.
One instance is normally sufficient because the main checks iterate through account orders rather than only the chart symbol. Attaching multiple instances can cause competing close attempts and duplicate messages. Use one carefully tested configuration unless you have independently verified a special multi-instance design.
The chart timeframe is not used as a risk boundary. Broker server time and account order history matter for daily and weekly calculations. Make sure the Account History tab contains the required history and confirm the broker day before relying on daily counters.
Push notifications require a working MetaQuotes ID configuration in Tools > Options > Notifications. Email requires a tested configuration in Tools > Options > Email. A notification setting does not repair a failed close request; it reports successful actions where the source sends a message.
3. Account Scope and Order Selection
By default, the EA evaluates market orders across the account. It is not restricted to the symbol of the chart on which it is attached. The close-all routine also handles pending BUY LIMIT, BUY STOP, SELL LIMIT, and SELL STOP orders by deleting them.
Check only orders without Magic narrows applicable calculations and close actions to orders whose Magic Number is zero. This usually targets manual trades, but an EA can also submit orders with Magic Number zero. Conversely, a manually managed order with a nonzero Magic Number would be outside this filter. Test the actual order metadata produced by every trading tool on the account.
Take into calculation the running/opened positions controls more than floating P/L. When enabled, currently open market orders contribute to daily and weekly results, the day-trade and day-loss counters, and the current-opened-order counter. When disabled, the open-order counter remains zero in this source version, so Check max opened orders amount cannot provide its intended protection. Keep the running/opened-position option enabled if you use the open-order limit.
Count broker's commission and Count Swaps affect the daily, weekly, and loss-count calculations in which the source adds those costs. They do not change every rule. In particular, per-trade checks use floating order profit only; they do not add swap or commission to the per-trade threshold comparison.
4. How Limits Are Calculated
Absolute equity floor
With Check limit to close enabled, Limit to close (account currency) is treated as an account-equity level. The trigger occurs when current account equity is below that value. It is not a maximum-loss amount.
Example: on a USD account, setting the level to 9,000 means that the EA attempts to close monitored exposure when equity falls below USD 9,000.
Simple and trailing modes
Type of limit provides two values: SimpleLimit and TrailingLimit .
In SimpleLimit mode, the daily and weekly money limits compare the calculated result with the negative configured allowance. Closed market orders from the broker day or week are included. When running/opened positions are enabled, their floating results are added as well. The daily percentage drawdown compares the current daily result with an estimated start-of-day balance.
In TrailingLimit mode, the daily and weekly money limits compare current equity with a high-water equity value stored in a MetaTrader terminal global variable. Higher equity updates the high-water mark. When there are no monitored current-day trades, version 2.02 can move that reference down to current equity. This is not a documented calendar-day reset control, so inspect the chart information and test restart behavior before relying on the trailing reference.
Broker day and week
Daily history is selected by broker-server calendar date. Weekly history starts from the calculated Monday boundary in broker-server time. Deposits and withdrawals recorded during the current day are identified separately rather than treated as ordinary market-order profit, but you should still recheck displayed values after any balance operation.
Exact comparison boundaries
The following boundaries matter when testing:
- The daily trade-count trigger acts when the count is equal to or greater than the configured value.
- Daily losing-trade count, consecutive-loss count, open-order count, and Anti Grid act only when the measured value is strictly greater than the configured value.
- The equity floor acts below the configured equity level, not at exact equality.
- Simple daily and weekly losses act after the result is more negative than the allowance.
- Daily drawdown and per-trade percentage loss act after the measured percentage is below the negative limit.
- Daily profit, daily profit percentage, and per-trade profit act after the measured result is above the configured target.
For example, Max opened orders amount = 5 permits five counted open market orders and acts when the count reaches six. Max amount of losses per day = 5 acts after a sixth counted losing trade, not on the fifth. By contrast, Max amount of day trades = 5 acts when the count reaches five.
5. Input Parameters
The labels below reproduce the user-facing source comments, including the original spelling of Check max amoumt of day trades .
Equity, daily, and weekly controls
| Input label | Purpose and source-backed behavior |
|---|---|
| Check limit to close | Enables the absolute account-equity floor. |
| Limit to close (account currency) | Equity level below which monitored orders are closed. |
| Check day limit to lose | Enables the daily money-loss rule. |
| Type of limit | Selects SimpleLimit or TrailingLimit . |
| Day limit to lose (account currency) | Positive daily allowance expressed in deposit currency. |
| Check max drawdown percentage per day | Enables the daily percentage drawdown rule. |
| Max drawdown per day (percent) | Positive percentage used as the daily drawdown boundary. |
| Check max profit percentage per day | Enables closing after the daily profit percentage is exceeded. |
| Max profit per day (percent) | Positive daily percentage target. |
| Check week limit to close | Enables the weekly money-loss rule. |
| Week limit to lose (account currency) | Positive weekly loss allowance in deposit currency. |
| Check max profit per day limit | Enables the daily money-profit target. |
| Profit day limit to close (account currency) | Daily result or observed daily peak above which current monitored exposure is closed. |
Individual-trade controls
| Input label | Purpose and source-backed behavior |
|---|---|
| Check max loss per trade | Enables a floating money-loss check for each selected order. |
| Max loss per trade (account currency) | Positive money amount; the order is closed when floating order profit is below its negative. |
| Check max profit per trade | Enables a floating profit target for each selected order. |
| Max profit per trade (account currency) | Positive money amount; the order is closed when floating order profit is above it. |
| Check max loss percentage per trade | Enables a per-trade loss check relative to account balance. |
| Max loss per trade (percentage) | Positive percentage; the comparison uses floating order profit divided by account balance. |
These three checks operate order by order. Their threshold test does not add swap or commission. If a selected order reaches a limit, the EA sends a terminal alert, attempts to close that order, and optionally sends push or email messages.
Activity and exposure controls
| Input label | Purpose and source-backed behavior |
|---|---|
| Check max amoumt of day trades | Enables the current broker-day trade-count rule. |
| Max amount of day trades | Acts when the counted total is equal to or above this value. |
| Check max losses per day | Enables the losing-trade counter for the broker day. |
| Max amount of losses per day | Acts when counted daily losses are greater than this value. |
| Check max losses in a row | Enables the consecutive-loss scan for the current broker day. |
| Max amount of losses in a row | Acts when consecutive losses are greater than this value. |
| Check only orders without Magic | Restricts applicable orders to Magic Number zero. |
| Check max opened orders amount | Enables the current-opened-market-order rule. |
| Max opened orders amount | Acts when the count is greater than this value. |
| Close opened orders to fit the limit (not all) | If enabled, attempts to close one selected excess order; otherwise closes all monitored orders and deletes monitored pending orders. |
| Anti Grid | Enables a same-symbol, same-direction order-count rule. |
| Max orders in one direction of grid | Maximum permitted BUY or SELL count on one symbol before the source closes one excess order. |
Anti Grid counts BUY and SELL directions separately for each symbol. If the BUY count is too high, the source selects the lowest-priced BUY for closure. If the SELL count is too high, it selects the highest-priced SELL. This is a mechanical exposure rule, not an assessment of strategy quality.
Calculation options
| Input label | Purpose and source-backed behavior |
|---|---|
| Take into calculation the running/opened positions | Includes selected open market orders in aggregates and enables the meaningful open-order counter. |
| Count broker's commission | Adds recorded commission in supported daily, weekly, and losing-trade calculations. |
| Count Swaps | Adds recorded swap in supported daily, weekly, and losing-trade calculations. |
Actions, messages, and display
| Input label | Purpose and source-backed behavior |
|---|---|
| Close terminal after limit overrun | Allows terminal shutdown after one of the supported breach flags. |
| Turn on info | Displays enabled rules and current measurements on the chart. |
| Close terminal immediately | Closes immediately when a supported breach is active instead of applying the source timer condition. |
| Close chart with other EA after limit overrun | Closes other open charts whose symbol matches the configured symbol after a supported breach. |
| Chart with symbols that will be closed after limit overrun | Exact chart symbol to match, including any broker suffix. |
| Seconds before close | Initializes the terminal-close time offset when the EA starts. In version 2.02 it is measured from EA initialization, not from the moment of a later breach. |
| Send PUSH notifications | Sends configured MetaTrader push messages after supported successful close or delete actions. |
| Send Email notifications | Sends configured email after supported successful close or delete actions. |
| Font size | Size of the on-chart information labels. |
| Font color | Color of the on-chart information labels. |
6. Close, Delete, Chart, and Terminal Actions
The account-wide close routine iterates through selected orders. It closes BUY orders at the current Bid, SELL orders at the current Ask, and deletes the four supported pending-order types. Each request can fail independently, and the terminal alert reports common errors such as market closure, off quotes, requotes, insufficient rights, or disabled automated trading.
Close opened orders to fit the limit (not all) changes only the open-order-count response. It attempts one close or delete instead of flattening all selected exposure. Other account-level breaches still use the all-orders routine.
The chart-close action scans other charts for an exact symbol match and excludes the RiskManager chart itself. If several other charts use the same symbol, each matching chart can be closed. A broker suffix matters: EURUSD and EURUSD.a are different strings.
The terminal-close timer has an important version 2.02 boundary. Seconds before close sets a timestamp during EA initialization. It is not restarted at the breach. If the EA has already been running longer than that interval when a supported breach occurs, the non-immediate condition can already be satisfied and terminal closure can occur without a fresh post-breach delay.
The source includes only specific breach flags in the chart and terminal shutdown condition: equity floor, daily or weekly loss, daily drawdown, day-trade count, daily-loss count, consecutive-loss count, open-order count, and Anti Grid. Per-trade and daily profit controls close applicable orders, but profit controls are not part of the chart-or-terminal shutdown condition in version 2.02. Build any stop-after-profit workflow around this documented boundary rather than assuming that every close reason also closes the chart or terminal.
7. Configuration Examples
These examples illustrate mechanics and are not financial advice.
Manual trading guard
- Set Check only orders without Magic to true.
- Enable Check day limit to lose and choose a positive Day limit to lose (account currency) .
- Enable Check max amoumt of day trades and set Max amount of day trades .
- Enable Check max losses in a row and set Max amount of losses in a row .
- Keep Take into calculation the running/opened positions enabled.
This configuration focuses on Magic Number zero orders and can stop current monitored exposure when daily activity or loss rules are exceeded.
Absolute equity and daily buffer
For an account near USD 10,000, a trader might enable Check limit to close with Limit to close (account currency) = 9000 , then use a smaller internal daily allowance than any external maximum. The absolute floor protects a fixed equity level, while the daily rule responds to the broker-day result. The values must be chosen for the account and tested under realistic spread and slippage.
Open-order and grid controls
- Set Take into calculation the running/opened positions to true.
- Enable Check max opened orders amount with Max opened orders amount = 5 .
- Enable Anti Grid with Max orders in one direction of grid = 3 .
The open-order rule acts on a sixth counted open market order. Anti Grid acts on a fourth same-direction market order for the same symbol.
Trailing equity mode
Select TrailingLimit , enable the daily or weekly money limit, and observe the displayed high-water equity during a demo test. Restart MetaTrader, use an account with no active trades, and verify how the terminal global variable behaves before applying the configuration to a live workflow.
8. Controlled Demo Testing
- Use a demo account with minimum-volume positions.
- Attach one RiskManager instance and enable AutoTrading.
- Start with every protection switch disabled.
- Enable Turn on info and confirm the chart displays the intended rule.
- Test one rule at a time with a deliberately small, safe threshold.
- Verify the exact equality boundary for the trade-count rule and the strictly-greater boundary for loss-count and open-order rules.
- Test a market order and a pending order separately.
- If using the Magic filter, compare a manual order with an EA order whose Magic Number is nonzero.
- Inspect the Experts and Journal tabs for close errors.
- Test push and email delivery separately.
- Test chart closure with an expendable chart and exact broker symbol.
- Test terminal closure only after every other EA and unsaved task is protected.
- Restore realistic limits and restart the test once more.
Record the configured values, broker server date, account balance/equity, open orders, and observed actions. A single successful close is not proof that all rules, symbols, order types, or market conditions will behave identically.
9. Operating Boundaries and Practical Safeguards
- Keep MetaTrader 4 online and the RiskManager chart open.
- Use an execution buffer below any broker or evaluation limit.
- Recheck account currency before entering money values.
- Confirm that history is loaded for the broker day and week.
- Treat push and email as monitoring, not as a substitute for close execution.
- Revalidate after a product update, broker migration, symbol-suffix change, deposit, withdrawal, or terminal reinstall.
- Do not assume that profit targets stop the source of new trades.
- Do not assume that Seconds before close provides a fresh grace period after every breach.
- Keep the running/opened-position calculation enabled when using the open-order limit.
- Use a separate strategy-level lock if another EA can immediately reopen exposure.
10. Troubleshooting
The EA displays information but does not close an order
Confirm AutoTrading, EA trading permission, market availability, connection, and broker permissions. Review Experts and Journal messages. A pending order is deleted by the account-wide routine, while per-trade profit/loss checks are intended for market orders with floating profit.
The daily result differs from my calculation
Check broker server date, Take into calculation the running/opened positions , Count broker's commission , Count Swaps , and the Magic Number filter. Floating values can move between ticks, and per-trade rules use a narrower profit measure than aggregate daily calculations.
The open-order limit never triggers
Make sure Take into calculation the running/opened positions is enabled. Version 2.02 increments the current-opened-order counter inside that calculation block.
The terminal closed sooner than expected
Seconds before close establishes its timestamp when the EA initializes. If the EA has been running longer than the interval, a later supported breach can satisfy the timer immediately.
Daily loss closes trades but another EA reopens them
Closing exposure does not automatically disable every trading source. Use the chart-close option with the exact symbol of the other EA's chart, use terminal closure where appropriate, or add an independent strategy lock.
The chart-close option does not find the other EA
Use the exact broker symbol including suffix or prefix, and remember that the RiskManager chart itself is excluded.
11. Frequently Asked Questions
Does the chart symbol limit protection? No. The main routines iterate through account orders. The configured chart symbol is used specifically for the optional other-chart closure action.
Does it open trades or generate signals? No. The validated source monitors and closes or deletes orders; it does not submit new entry orders.
Can it monitor only manual orders? Check only orders without Magic selects Magic Number zero. That usually includes manual orders, but any EA can also use zero.
Are swap and commission included everywhere? No. They are optional in aggregate history and running-result calculations. Per-trade thresholds use floating order profit only.
Does a limit always close at the exact value? No. Detection and execution occur through the terminal and broker. The final result can differ because of price movement, spread, slippage, connectivity, or a rejected request.
Will a daily profit target close the terminal? It closes current monitored orders when its rule is exceeded, but the profit flags are outside the version 2.02 chart/terminal shutdown condition.
Will it work while MetaTrader is offline? No. The EA requires a running and connected MetaTrader 4 terminal.
12. Final Checklist
- The installed product is RiskManager for MetaTrader 4 version 2.2.
- One instance is attached to the intended account.
- AutoTrading and EA trading permission are enabled.
- Money limits match the account deposit currency.
- Broker server day and history are verified.
- The Magic Number scope is understood.
- Running/opened positions, commission, and swap settings match the intended calculation.
- Equality and strictly-greater trigger boundaries were tested.
- Pending-order deletion was tested.
- Notifications were tested independently.
- Chart-symbol matching includes any broker suffix.
- Terminal-close timer behavior was tested from a fresh EA start and after a long runtime.
- Limits include an execution buffer.
- The trading source cannot immediately reopen exposure after a breach.
RiskManager is best used as a tested final enforcement layer alongside disciplined position sizing, broker-side Stop Loss orders, strategy-level limits, stable infrastructure, and regular supervision.


