
How to connect TradingView to MT5
Step-by-step guide to set up OrderRailEA Expert Advisor
OrderRailEA connects your MetaTrader 5 terminal to OrderRail, allowing you to execute TradingView webhook signals automatically in MT5.
Prerequisites
Before you begin, make sure you have:
- MetaTrader 5 terminal installed
- MT5 account with a broker
- OrderRail account with an active MT5 terminal configured
- API key from OrderRail (generated in the config page)
Installation
Step 1: Download the EA file
Download the OrderRailEA.mq5 file below, or copy it from your OrderRail installation.
Step 2: Install in MT5
- Open MetaTrader 5
- Go to
File→Open Data Folder - Navigate to
MQL5→Experts - Copy
OrderRailEA.mq5into this folder - Restart MT5 or press
F5in the Navigator window to refresh
Step 3: Compile the EA
- In MT5, open the
Navigatorwindow (View → Navigator or Ctrl+N) - Find
OrderRailEAunderExpert Advisors - Right-click and select
Compile - Check the
Toolboxwindow for any compilation errors
Configuration
Step 1: Get your API key
Log into your OrderRail account and navigate to the config page. In the MT5 settings section, create or view your MT5 terminal. Copy the API key that is displayed.
⚠️ Important: The API key is only shown once. Save it securely before closing the dialog.
Step 2: Configure the EA
- Drag
OrderRailEAfrom Navigator onto any chart - In the EA settings dialog, configure the following:
BaseUrl:
Your OrderRail API URL (e.g., https://api.orderrail.net)
ApiKey:
Paste your MT5 API key from OrderRail
TerminalId:
Unique identifier for this MT5 terminal (e.g., vps-1)
PollSeconds:
How often to check for commands (default: 2 seconds)
DeviationPoints:
Slippage tolerance in points (default: 20)
Click OK to start the EA.
Step 3: Enable algorithmic trading
Before the EA can execute trades, you must enable algorithmic trading in MT5:
- Look for the
AutoTradingbutton in the MT5 toolbar (usually at the top) - Click the button to enable it (it should turn green/active)
- Alternatively, go to
Tools→Options→Expert Advisorsand check "Allow algorithmic trading"
⚠️ Important: If algorithmic trading is disabled, the EA will reject all trade commands with "Trading not allowed now" error.
Step 4: Verify connection
- Check the
Expertstab in the Terminal window - You should see "OrderRailExecutorEA initialized" message
- The EA will automatically poll for commands every
PollSecondsseconds
Symbol Mapping
MT5 uses different symbol names than TradingView. Configure symbol mappings in the OrderRail config page to map TradingView tickers to MT5 symbols.
For example, a TradingView ticker like BTCUSD might map to an MT5 symbol like BTCUSD or a broker-specific name like BTCUSD.ecn.
The EA will use the symbol name as provided in the command from the backend, so ensure your symbol mappings are configured correctly.
Troubleshooting
EA not starting
- Check that the EA is compiled without errors
- Verify BaseUrl and ApiKey are set correctly
- Check MT5's
Expertstab for error messages
Commands not executing
- Verify API key is correct in EA settings
- Check that
AutoTradingbutton is enabled (green/active) in MT5 toolbar - If you see "Trading not allowed now" error, ensure algorithmic trading is enabled in MT5 settings
- Check backend logs for command creation
- Ensure symbol name matches your broker's symbol format
- Check MT5's
Journaltab for execution errors
Network errors
- Ensure MT5 is allowed through firewall
- Verify BaseUrl is accessible from your network
- Check that the OrderRail backend is running and accessible
Security Notes
- Never share your API key
- The API key is stored in MT5's EA settings (encrypted by MT5)
- Regenerate API key if compromised
- Use HTTPS for BaseUrl
Next Steps
Once your EA is configured and running, configure your symbol mappings and TradingView webhooks in the OrderRail config page.