Skip to content

GentlemanHu/MetatraderTelegramHelper

Repository files navigation

MetaTrader Telegram Helper

License: MIT Python 3.8+ MetaTrader 5 Telegram Bot API

A powerful Telegram bot for managing MetaTrader 5 positions and accounts. Control your trading operations directly from Telegram with a user-friendly interface.

Features

  • 🌐 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

Installation

Prerequisites

  • Python 3.8 or higher
  • MetaTrader 5 installed
  • Telegram Bot Token (get from @BotFather)

Setup

  1. Clone the repository:

    git clone https://github.com/GentlemanHu/MetatraderTelegramHelper.git
    cd MetatraderTelegramHelper
  2. Install dependencies:

    pip install -r requirements.txt
  3. Create a .env file 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
    
  4. Run the bot:

    python -m mt_manager

Usage

Basic Commands

  • /start - Start the bot
  • /help - Show help message
  • /status - Show account status and positions
  • /symbols - List all available symbols
  • /keyboard - Show quick access keyboard

Position Management

  • /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)

Stop Loss/Take Profit Management

  • /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

Monitoring

  • /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

Settings

  • /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

Configuration

The bot supports two levels of configuration:

  1. Environment Variables: Set in .env file or system environment
  2. 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.

Multi-Account Management

You can add multiple MT5 accounts and switch between them:

  1. Add a new account: /add_account name login password server
  2. View accounts: /accounts
  3. Switch account: Select from the list in /accounts

Internationalization

The bot supports multiple languages. To change the language:

  1. Use the /language command
  2. Select your preferred language from the list

To add a new language:

  1. Create a new JSON file in mt_manager/i18n/ (e.g., fr.json)
  2. Copy the structure from an existing language file and translate the values
  3. Add the language code to AVAILABLE_LANGUAGES in mt_manager/i18n/__init__.py

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

About

A powerful Telegram bot for managing MetaTrader 5 positions and accounts. Control your trading operations directly from Telegram with a user-friendly interface.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages