OrderRail

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

  1. Open MetaTrader 5
  2. Go to FileOpen Data Folder
  3. Navigate to MQL5Experts
  4. Copy OrderRailEA.mq5 into this folder
  5. Restart MT5 or press F5 in the Navigator window to refresh

Step 3: Compile the EA

  1. In MT5, open the Navigator window (View → Navigator or Ctrl+N)
  2. Find OrderRailEA under Expert Advisors
  3. Right-click and select Compile
  4. Check the Toolbox window 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

  1. Drag OrderRailEA from Navigator onto any chart
  2. 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:

  1. Look for the AutoTrading button in the MT5 toolbar (usually at the top)
  2. Click the button to enable it (it should turn green/active)
  3. Alternatively, go to ToolsOptionsExpert Advisors and 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 Experts tab in the Terminal window
  • You should see "OrderRailExecutorEA initialized" message
  • The EA will automatically poll for commands every PollSeconds seconds

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 Experts tab for error messages

Commands not executing

  • Verify API key is correct in EA settings
  • Check that AutoTrading button 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 Journal tab 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.