Basket Goal Manager
A trader running several correlated positions - a basket of currency pairs on one theme, or several entries from the same setup - often cares about the combined result more than any single ticket. Watching each order's own P/L column and doing the mental addition every time the market moves is slow and error-prone, and it is easy to miss the moment the combined result actually crosses a target. This EA does the addition continuously. It sums floating profit, swap and commission across every open market order matching a magic filter (or every open order on the account, filter set to -1), in either money terms or R-multiples, and reports live progress toward a configurable goal in the on-chart panel. R-multiple mode needs a money value for "1R" as an input, since the EA does not open trades itself and so cannot infer a stop-based risk figure from the basket. The moment the goal is reached it can close every matching order and alert - or, with closing switched off, simply keep displaying progress for a trader who wants the notification without the automation. Notes and limitations - Only market orders (OP_BUY/OP_SELL) count toward the basket; pending orders carry no floating P/L and are ignored. - R-multiple mode's "1R" is a single fixed money value supplied by the trader, not computed per-order from each order's own stop distance - it assumes a basket of broadly similar-risk entries. - Closing is a best-effort loop with a short retry on the classic transient trade errors (requote, off-quotes, busy context); a persistent broker-side rejection on one ticket is logged and skipped rather than retried indefinitely. - The goal-reached alert fires once per basket; it will not repeat every tick while the closed/empty basket sits at zero, but will fire again if a new basket is built up afterward and reaches the goal too.
Expert advisor · MT5 · v1.0 · Free
About Basket Goal Manager
Basket Goal Manager is an expert advisor (trading robot) for MetaTrader 5. It has 8 settings, such as Goal mode, Money goal and R goal. MQL source code included.
Files in the download: BasketGoalManager.ex5, BasketGoalManager.mq5, BasketGoalManager.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Goal mode | GOAL_MONEY | How the goal is measured |
| Money goal | 100.0 | Close the basket at this much combined profit (money mode) |
| R goal | 2.0 | Close the basket at this many combined R (R mode) |
| One r value usd | 50.0 | Money value that counts as "1R" (R mode only) |
| Magic filter | -1 | Only include this magic number, -1 = every position on the account |
| Close on goal | true | Actually close the basket once the goal is reached |
| Alert on goal | true | Popup Alert() when the goal is reached |
| Update every secs | 1 | Minimum seconds between panel refreshes |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: MT5 Expert Advisor · MQL5 Source Code