Get started with Tradingview MT5 Gateway in minutes
Tradingview MT5 Gateway bridges the gap between your TradingView alerts and MetaTrader 5 terminal. It allows you to automate your trading strategies by converting TradingView alerts into automated executions on MT5.
For enhanced security, we strongly recommend enabling Two-Factor Authentication on your account. This adds an extra layer of protection by requiring a time-based code from your mobile device when logging in.
To ensure all signals and logs are displayed in your local time:
* The system attempts to auto-detect your browser timezone upon your first login.
Our platform uses "Connections" to pair your TradingView strategies with specific MetaTrader 5 accounts.
Download the TvGatewayEA.ex5 file from the Downloads page. Place it in your MT5 Data Folder under MQL5/Experts/. Refresh the Experts list in MT5 and drag the EA onto any chart.
In the EA settings input:
* The EA automatically appends your MT5 account number to the request (e.g., `?token=...&account=123456`) to authorize the signal retrieval.
In TradingView, create a new alert on your strategy or indicator. In the "Webhook URL" field, paste the webhook URL provided in your dashboard (e.g., https://www.uat.tvmt5gateway.com/api/tv-webhook).
In the "Message" field, use the JSON format provided. Make sure to use the specific "TV Secret" for your Connection.
{
"secret": "YOUR_TV_SECRET_FROM_DASHBOARD",
"action": "buy",
"symbol": "XAUUSD",
"volume": 0.1,
"price": "{{close}}",
"sl": "{{plot("Stop Loss")}}",
"tp": "{{plot("Take Profit")}}"
}
This script sends a BUY signal when EMA 20 crosses over EMA 50, and a CLOSE signal when it crosses under.
//@version=5
strategy("TV-MT5 MA Cross", overlay=true)
// Inputs
secret = input.string("CHANGE_ME", "Webhook Secret")
// Indicators
ema20 = ta.ema(close, 20)
ema50 = ta.ema(close, 50)
plot(ema20, color=color.green)
plot(ema50, color=color.red)
// Logic
longCondition = ta.crossover(ema20, ema50)
closeCondition = ta.crossunder(ema20, ema50)
// JSON Payloads
buy_json = '{"secret": "' + secret + '", "action": "buy", "symbol": "' + syminfo.ticker + '", "volume": 0.1}'
close_json = '{"secret": "' + secret + '", "action": "close_symbol", "symbol": "' + syminfo.ticker + '"}'
// Execution
if (longCondition)
strategy.entry("Long", strategy.long, alert_message=buy_json)
if (closeCondition)
strategy.close("Long", alert_message=close_json)
This script BUYS when RSI < 30 and SELLS when RSI > 70.
//@version=5
strategy("TV-MT5 RSI Strategy", overlay=true)
secret = input.string("CHANGE_ME", "Webhook Secret")
rsi = ta.rsi(close, 14)
// Triggers
buySignal = ta.crossover(rsi, 30)
sellSignal = ta.crossunder(rsi, 70)
// JSON
buy_msg = '{"secret": "' + secret + '", "action": "buy", "symbol": "' + syminfo.ticker + '", "volume": 0.1, "comment": "RSI Buy"}'
sell_msg = '{"secret": "' + secret + '", "action": "sell", "symbol": "' + syminfo.ticker + '", "volume": 0.1, "comment": "RSI Sell"}'
if (buySignal)
strategy.entry("Long", strategy.long, alert_message=buy_msg)
if (sellSignal)
strategy.entry("Short", strategy.short, alert_message=sell_msg)
Once set up, every time your alert triggers, the signal is sent to our gateway. The EA on your MT5 terminal polls for pending signals matching its token and account, executing them automatically (batch processing is supported). You can monitor all signals in real-time from your dashboard.
Check if "Algo Trading" is enabled in MT5 and if the EA is running (smiley face icon). Also verify the symbol name matches exactly. If you set an "MT5 Account Number" in your connection, ensure the EA is running on that exact account.
Verify your TV Secret is correct. Check the webhook log in TradingView for response codes.