A powerful Telegram bot for managing MetaTrader 5 positions and accounts. Control your trading operations directly from Telegram with a user-friendly interface.
- 🌐 Multi-language Support: Available in English and Chinese, easily extendable to other languages
- 👥 Multi-account Management: Switch between different MT5 accounts seamlessly
- 📊 Position Management: View, close, and modify positions
- 🛡️ Stop Loss/Take Profit: Set, modify, or remove SL/TP for positions
- 🔍 Position Monitoring: Automatically set take profit for new positions
- ⚙️ Runtime Configuration: Change settings without restarting the bot
- 📱 Custom Keyboards: Quick access to common operations
- 🔐 Admin-only Access: Secure access control
- Python 3.8 or higher
- MetaTrader 5 installed
- Telegram Bot Token (get from @BotFather)
-
Clone the repository:
git clone https://github.com/GentlemanHu/MetatraderTelegramHelper.git cd MetatraderTelegramHelper -
Install dependencies:
pip install -r requirements.txt
-
Create a
.envfile with your configuration:# MT5 Configuration MT5_SERVER=your_server MT5_LOGIN=your_login MT5_PASSWORD=your_password MT5_PATH=path_to_mt5_terminal.exe # Telegram Configuration TELEGRAM_TOKEN=your_telegram_bot_token TELEGRAM_ADMIN_IDS=your_telegram_id,another_admin_id # Trading Configuration DEFAULT_TP_PIPS=20.0 DEFAULT_SL_PIPS=30.0 BREAKEVEN_BUFFER_PIPS=5.0 DEFAULT_MONITORING_MINUTES=30 # Bot Configuration BOT_LANGUAGE=en REQUIRE_CONFIRMATION=True -
Run the bot:
python -m mt_manager
/start- Start the bot/help- Show help message/status- Show account status and positions/symbols- List all available symbols/keyboard- Show quick access keyboard
/close_profit [symbol]- Close all profitable positions/close_buy_profit [symbol]- Close all profitable BUY positions/close_sell_profit [symbol]- Close all profitable SELL positions/close_all [symbol]- Close all positions (profitable or not)
/move_sl_breakeven [buffer_pips] [symbol]- Move SL to breakeven for profitable positions/remove_all_sl [symbol]- Remove all stop losses/remove_all_tp [symbol]- Remove all take profits/set_sell_sltp [sl_pips] [tp_pips] [symbol]- Set SL/TP for all SELL positions/set_buy_sltp [sl_pips] [tp_pips] [symbol]- Set SL/TP for all BUY positions
/monitor [minutes] [tp_pips] [symbol]- Start monitoring for new positions/monitor_status- Show status of active monitoring sessions/stop_monitor [user_id]- Stop monitoring session
/toggle_confirmation- Toggle confirmation dialogs/settings- Show and modify settings/language- Change interface language/accounts- Manage and switch between MT5 accounts/config- View and modify configuration
The bot supports two levels of configuration:
- Environment Variables: Set in
.envfile or system environment - Runtime Configuration: Stored in
config.json, can be modified while the bot is running
The bot will first look for configuration in config.json, and if not found, it will use environment variables.
You can add multiple MT5 accounts and switch between them:
- Add a new account:
/add_account name login password server - View accounts:
/accounts - Switch account: Select from the list in
/accounts
The bot supports multiple languages. To change the language:
- Use the
/languagecommand - Select your preferred language from the list
To add a new language:
- Create a new JSON file in
mt_manager/i18n/(e.g.,fr.json) - Copy the structure from an existing language file and translate the values
- Add the language code to
AVAILABLE_LANGUAGESinmt_manager/i18n/__init__.py
This project is licensed under the MIT License - see the LICENSE file for details.
- python-telegram-bot - Telegram Bot API wrapper
- MetaTrader 5 - Trading platform
- python-dotenv - Environment variable management