# Universal Smart Manual Trade Manager MT5 v1.00
## What the EA does
Universal Smart Manual Trade Manager MT5 is a protective and management Expert Advisor for manually opened trades. It does not open new entries by itself. It only adopts already open positions that pass the selected filters, and can add missing SL/TP, manage break-even, profit lock, ATR trailing, send Telegram notifications, and display status information on the chart.
The default setup is intentionally safe: the EA manages only manual positions (`magic = 0`) on the current chart symbol. This minimizes the risk of accidentally interfering with another trading robot.
This Expert Advisor is a manual trade management utility. It does not open trades automatically and does not use martingale, grid, arbitrage, scalping or news trading logic.
## Important warning
The EA is universal, but every broker can have different symbol conditions, tick value, tick size, minimum stop distance, freeze level, and volume steps. Before using the EA live, always test the exact symbol and broker on a demo account or with a very small position.
The EA reads broker symbol properties such as:
- `SYMBOL_TRADE_TICK_VALUE`
- `SYMBOL_TRADE_TICK_SIZE`
- `SYMBOL_DIGITS`
- `SYMBOL_POINT`
- `SYMBOL_TRADE_STOPS_LEVEL`
This allows it to calculate risk per 1 lot in a universal way. However, for exotic CFDs and non-standard broker symbols, the risk calculation should always be manually verified.
---
# 1. General settings
## InpManagerEnabled
Turns EA management on or off.
- `true` = the EA manages positions according to the filters
- `false` = the EA does not manage positions
## InpPresetProfile
Quick preset profile. When this is set to anything other than `CUSTOM`, the EA internally overrides selected detailed parameters.
- `HM_PROFILE_CUSTOM` = exact input values are used
- `HM_PROFILE_CONSERVATIVE` = wider ATR SL, later break-even, more conservative behavior
- `HM_PROFILE_BALANCED` = default trading management mode: ATR SL + BE + Lock
- `HM_PROFILE_ACTIVE` = more active mode with ATR trailing
Recommendation: use `CUSTOM` while testing and fine-tuning. For regular users, `BALANCED` is the best default.
## InpManageScope
Defines whether the EA manages only the current chart symbol or all account symbols.
- `HM_SCOPE_CURRENT_SYMBOL` = manages only the chart symbol, for example only XAUUSD on an XAUUSD chart
- `HM_SCOPE_ALL_SYMBOLS` = one EA instance scans and manages all open positions on the account
The safe default is `CURRENT_SYMBOL`.
## InpManageManualPositionsOnly
- `true` = the EA manages only manual positions with `magic = 0`
- `false` = the EA may also manage positions opened by another EA if they pass the remaining filters
Recommendation for the public version: keep this `true` by default.
## InpUseMagicNumberFilter / InpMagicNumberFilter
Optional filter by magic number.
Typical use:
- manual trades: `InpManageManualPositionsOnly = true`, magic filter disabled
- specific robot: `InpManageManualPositionsOnly = false`, `InpUseMagicNumberFilter = true`, `InpMagicNumberFilter = magic number of that robot`
## InpAdoptExistingPositionsOnInit
When `true`, the EA adopts already open positions after startup if they pass the filters.
## InpSendExistingAdoptionMessages
When `true`, the EA sends Telegram messages for positions that already existed before the EA was started. The default is `false` to avoid message spam after VPS restart or migration.
## InpTimerSeconds
How often the management loop runs, in seconds. The default value `2` is a good compromise. Setting this to `1` is not recommended when multiple symbols or Telegram are used.
## InpDeviationPoints
Maximum deviation for close operations and trade requests. It is not critical for normal SL/TP management.
---
# 2. Automatic SL/TP placement
## InpSLTPMode
Defines how the EA calculates SL/TP.
### HM_SLTP_NONE
The EA will not automatically add SL/TP.
Useful when you only want to use BE/trailing on positions where SL is entered manually.
### HM_SLTP_FIXED_POINTS_RR
Simple mode:
- SL = fixed number of points
- TP = SL × RR
Main parameters:
- `InpFixedSLPoints`
- `InpAddSpreadToFixedSL`
- `InpRewardRiskRatio`
### HM_SLTP_ATR_SPREAD_RR
Recommended default.
Calculation:
```text
SL distance = ATR × InpSL_ATR_Multiplier + Spread × InpSpreadBufferMultiplier
TP distance = SL distance × InpRewardRiskRatio
```
Main parameters:
- `InpATRTimeframe`
- `InpATRPeriod`
- `InpSL_ATR_Multiplier`
- `InpSpreadBufferMultiplier`
- `InpRewardRiskRatio`
- `InpMinSLPoints`
- `InpMaxSLPoints`
### HM_SLTP_SWING_ATR_BUFFER_RR
More advanced mode.
- BUY SL = last swing low − ATR buffer
- SELL SL = last swing high + ATR buffer
- TP = RR × risk
Main parameters:
- `InpSwingTimeframe`
- `InpSwingLookbackBars`
- `InpSwingStartShift`
- `InpSwingATRBufferMultiplier`
- `InpRewardRiskRatio`
## InpPlaceMissingSL / InpPlaceMissingTP
Defines whether the EA adds missing SL and TP.
## InpReplaceExistingSL / InpReplaceExistingTP
When `true`, the EA may replace existing SL/TP values.
Recommendation: keep this `false` for regular users so the EA respects manually entered levels.
## InpAutoAdjustToMinStopLevel
When the broker does not allow SL/TP too close to the current price, the EA attempts to move the level to the minimum allowed distance.
---
# 3. Break-even, profit lock, and trailing
## InpManagementMode
### HM_MGMT_NONE
No exit management.
### HM_MGMT_CONSERVATIVE_BE
After reaching `InpBETriggerR`, the EA moves SL to entry plus a small offset.
Example:
```text
InpBETriggerR = 1.00
InpBEOffsetR = 0.03
```
After reaching +1R, SL is moved to approximately +0.03R.
### HM_MGMT_BE_AND_LOCK
Recommended default.
Typical behavior:
```text
0.75R -> SL to BE + 0.03R
1.20R -> lock 0.30R
1.80R -> lock 0.80R
```
Parameters:
- `InpBETriggerR`
- `InpBEOffsetR`
- `InpLock1TriggerR`
- `InpLock1R`
- `InpLock2TriggerR`
- `InpLock2R`
### HM_MGMT_ATR_TRAILING
After reaching `InpTrailStartR`, the EA starts moving SL using ATR trailing.
Parameters:
- `InpTrailATRTimeframe`
- `InpTrailATRPeriod`
- `InpTrailStartR`
- `InpTrailATRMultiplier`
## InpNeverLoosenSL
Very important protection. When `true`, SL is never moved to a worse level.
- for BUY positions, SL can only move up
- for SELL positions, SL can only move down
Recommendation: always keep this `true`.
## InpMinSecondsBetweenTradeMods
Protection against too frequent SL/TP modifications. The default is `8` seconds.
---
# 4. Daily safety guard
## InpUseDailySafetyGuard
Enables daily protection based on equity.
## InpMaxDailyLossMoney
Fixed money daily loss limit. `0` = disabled.
## InpMaxDailyLossPercent
Percentage daily loss limit calculated from start-of-day equity.
## InpSafetyAction
- `HM_SAFETY_ALERT_ONLY` = alert only
- `HM_SAFETY_DISABLE_MANAGEMENT` = after the limit is reached, the EA stops modifying positions
- `HM_SAFETY_CLOSE_MANAGED` = attempts to close managed positions
Recommendation for the first version: keep the default as `ALERT_ONLY`. Closing positions is an aggressive function and should be tested with the specific broker before live use.
---
# 5. Telegram
Telegram is optional. The EA works normally without Telegram.
## Inputs
- `InpUseTelegram` = enables/disables Telegram
- `InpTelegramBotToken` = bot token
- `InpTelegramChatId` = user or group chat ID
- `InpTelegramStatusMode` = status message detail level
- `InpStatusIntervalMinutes` = regular status interval
- `InpSendOpenCloseMessages` = adoption and close messages
- `InpSendSLTPModificationMessages` = SL/TP placement and modification messages
- `InpSendRiskStatusMessages` = regular risk/status messages
- `InpMinSecondsBetweenTelegramMessages` = minimum spacing between normal messages
- `InpMaxTelegramMessagesPerMinute` = maximum number of normal messages per minute
## Anti-spam protection
If the user opens or closes multiple trades in a short time, the EA may not send every individual notification. Some messages can be merged or skipped, and the next message may include the note:
```text
Note: X notification(s) were merged/skipped by anti-spam protection.
```
This is intentional protection against Telegram spam and unnecessary WebRequest calls.
---
# 6. What you will see on the chart
The chart panel displays:
- current symbol
- Bid/Ask
- spread
- ATR
- ATR/Spread
- suggested BUY SL
- suggested SELL SL
- risk per 1 lot for BUY
- risk per 1 lot for SELL
- number and lot size of open BUY/SELL positions
- open BUY/SELL profit/loss
- daily safety guard status
- management scope mode
---
# 7. Recommended configurations
## Safe default for one symbol
```text
InpManageScope = HM_SCOPE_CURRENT_SYMBOL
InpManageManualPositionsOnly = true
InpSLTPMode = HM_SLTP_ATR_SPREAD_RR
InpManagementMode = HM_MGMT_BE_AND_LOCK
InpNeverLoosenSL = true
InpUseTelegram = false for the first test
```
## One Hand Manager for the whole account
```text
InpManageScope = HM_SCOPE_ALL_SYMBOLS
InpManageManualPositionsOnly = true
```
Use only one EA instance in `ALL_SYMBOLS` mode. Do not run multiple Hand Managers in `ALL_SYMBOLS`, otherwise they may try to manage the same positions.
## Managing another robot by magic number
```text
InpManageManualPositionsOnly = false
InpUseMagicNumberFilter = true
InpMagicNumberFilter = the selected magic number
```
# Telegram setup for Universal Smart Manual Trade Manager MT5
## What you need
1. A Telegram account.
2. A created Telegram bot.
3. Bot token.
4. Chat ID.
5. WebRequest enabled in MT5.
## 1. Create a Telegram bot
1. In Telegram, search for `@BotFather`.
2. Send the command `/newbot`.
3. Enter a bot name, for example `My Trade Manager Bot`.
4. Enter a bot username. It must end with `bot`, for example `my_trade_manager_123_bot`.
5. BotFather will send you a token similar to:
```text
1234567890:ABCdefGhIJKlmNoPQRstuVWxyz
```
Paste this token into the EA input:
```text
InpTelegramBotToken
```
## 2. Get your Chat ID
The simplest method:
1. Open your new bot in Telegram.
2. Click `Start` or send it a message, for example `test`.
3. Open this address in your browser:
```text
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
```
4. In the response, find the `chat` object and its `id` value.
5. Paste this number into the EA input:
```text
InpTelegramChatId
```
Note: group chat IDs can be negative numbers. That is normal.
## 3. Enable WebRequest in MT5
MT5 must allow the Telegram API URL:
1. Open `Tools`.
2. Select `Options`.
3. Open the `Expert Advisors` tab.
4. Check `Allow WebRequest for listed URL`.
5. Add exactly this address:
```text
https://api.telegram.org
```
Without this step, the EA will report a WebRequest error in the MT5 Journal.
## 4. Enable Telegram in the EA
Set these EA inputs:
```text
InpUseTelegram = true
InpTelegramBotToken = token from BotFather
InpTelegramChatId = your chat ID
InpStatusIntervalMinutes = 10
InpSendOpenCloseMessages = true
InpSendSLTPModificationMessages = true
InpSendRiskStatusMessages = true
```
## 5. Recommended anti-spam settings
```text
InpMinSecondsBetweenTelegramMessages = 20
InpMaxTelegramMessagesPerMinute = 3
```
If the user opens several trades in quick succession, the EA may skip or merge some messages. This is correct behavior and is intentional anti-spam protection.
Recommended text for product documentation:
```text
Telegram notifications include anti-spam protection. If multiple trades are opened, modified or closed within a short time, some individual notifications may be merged or skipped and summarized in a later message.
```
## 6. Test Telegram
After the EA is enabled, you should receive a message:
```text
Smart Manual Trade Manager started
```
If the message does not arrive:
1. Check the bot token.
2. Check the chat ID.
3. Make sure you sent at least one message to the bot.
4. Check that the WebRequest URL is allowed in MT5.
5. Check the `Experts` and `Journal` tabs in MT5.
## Security note
The Telegram bot token is sensitive. Do not publish it in screenshots, videos, product comments, or public support messages. If the token is exposed, regenerate it in BotFather and update the EA inputs.
# Deploying Universal Smart Manual Trade Manager MT5 on MT5 VPS
## Basic principle
MT5 VPS migrates the current local terminal environment to the virtual platform: open charts, attached Expert Advisors, indicators, and their input parameters. Therefore, before migration, it is important to prepare all charts locally exactly as they should run on the VPS.
## Adding Hand Manager next to the main trading robot
If a main trading EA is already intended to run on the VPS on a symbol such as UKOIL, and you want to add Hand Manager, prepare it locally like this:
1. Open the original UKOIL chart with the main trading EA.
2. Open a second chart of the same symbol, UKOIL.
3. Attach `Universal Smart Manual Trade Manager MT5` to the second chart.
4. Keep the safe Hand Manager default:
```text
InpManageScope = HM_SCOPE_CURRENT_SYMBOL
InpManageManualPositionsOnly = true
```
5. Confirm that both charts are running:
- chart 1: main trading EA
- chart 2: Hand Manager
6. Perform a new migration/synchronization to MT5 VPS.
7. Check the VPS Journal and verify that both Expert Advisors are running.
## Important warning
A new migration does not simply add a new chart to what is already running on the VPS. It transfers the current local terminal environment. Therefore, during migration, all charts and EAs that should remain on the VPS must be open locally.
If you leave only the Hand Manager chart open locally and run migration, you may accidentally overwrite the VPS environment without the original main trading robot.
## One symbol
For one symbol, the recommended setup is:
```text
Chart 1: symbol + main trading EA
Chart 2: same symbol + Hand Manager
```
In `CURRENT_SYMBOL` mode, Hand Manager will manage only manual positions on its chart symbol.
## Multiple symbols: oil and gold
Question: if a user has two charts on VPS, for example oil and gold, will Hand Manager manage manual trades on both?
The answer depends on `InpManageScope`.
### Option A: safe and recommended for most users
Use one Hand Manager instance per symbol.
Example:
```text
Chart 1: UKOIL + main EA or manual trading
Chart 2: UKOIL + Hand Manager, InpManageScope = CURRENT_SYMBOL
Chart 3: XAUUSD + main EA or manual trading
Chart 4: XAUUSD + Hand Manager, InpManageScope = CURRENT_SYMBOL
```
In this mode:
- Hand Manager on UKOIL manages only UKOIL.
- Hand Manager on XAUUSD manages only XAUUSD.
- The setup is clear and safe.
### Option B: one instance for the whole account
Use one Hand Manager instance with:
```text
InpManageScope = HM_SCOPE_ALL_SYMBOLS
```
In this mode, one Hand Manager can manage manual positions across all account symbols, for example UKOIL and XAUUSD.
Important rule:
```text
Run only one Hand Manager instance in ALL_SYMBOLS mode.
```
If two Hand Manager instances are running on the VPS and both are set to `ALL_SYMBOLS`, they may try to manage the same positions, send duplicate messages, and perform unnecessary SL/TP modifications.
## Recommended text for product documentation
```text
Default mode manages only the current chart symbol. To manage multiple symbols, attach one Hand Manager instance to each symbol chart. Advanced users may use ALL_SYMBOLS mode, but only one ALL_SYMBOLS instance should run on the account.
```
## Checklist after VPS migration
After migration, check:
1. VPS Journal.
2. Number of charts.
3. Number of running Expert Advisors.
4. Whether Algo Trading is enabled.
5. Whether Telegram sent the start message, if Telegram is enabled.
6. Whether the chart panel did not show errors locally before migration.
## Telegram on VPS
WebRequest settings must be prepared locally before migration. The allowed URL list must contain:
```text
https://api.telegram.org
```
After changing Telegram inputs or WebRequest settings, perform a new migration to VPS.
## Practical recommendation
For beginners and regular users, use `CURRENT_SYMBOL` mode and attach one Hand Manager to each symbol chart. Use `ALL_SYMBOLS` only if the user understands that one EA instance will manage all manual positions on the account.