Skip to content
Hookmode

TradingView

From a TradingView alert to an MT5 trade

Automate your TradingView trades in MetaTrader 5 with Hookmode. Connect your alerts, choose how trades close, and follow each signal through to your trading account.

From alert to tradeIllustrative example
  1. 01 · Your conditions

    TradingView

    An alert fires when your condition is met.

    Price levelAlert fires
  2. 02 · Your instruction

    Hookmode

    A preview of your alert's instruction.

    Open buy
    action
    open
    side
    buy
    Checks your configured rules
  3. 03 · Your account

    Windows + MT5

    Your desktop app sends the instruction to MetaTrader 5.

    Demo account
    Buy trade
    Trade opened
The broker's result returns to Hookmode.
Your conditions stay in TradingView. Hookmode follows your configured rules.

Your entry conditions stay in TradingView. When an alert fires, it sends Hookmode an instruction to open or close a trade. Hookmode checks your configured rules and sends the instruction to MetaTrader 5 through the Hookmode desktop app on your Windows device.

01

Prepare your trading account

Start with a connected MetaTrader 5 demo account. Install the Hookmode desktop app on a Windows PC and keep the device on and online while the automation runs.

Your connection in Hookmode
  1. Create a webhook

    Choose buy trades, sell trades, or both. Set the quantity and stop-loss distance. Add a take-profit distance if you want a fixed target.

  2. Add a portfolio rule

    Connect the webhook to your account. Check the broker's symbol and the resulting volume in lots before continuing.

A portfolio rule connects the webhook to a trading account and the symbol offered by its broker.
Connect your demo accountFollow the getting-started guide for device and account setup.
02

Connect your TradingView alert

Hookmode provides the two things your alert needs: an alert message and a webhook URL. Find them in your webhook's Setup panel.

The message
What to do: open a buy trade, close sell trades, or another supported action.
The webhook URL
Where to send it: the Hookmode address you paste into TradingView's notifications.
The Connect menu copies the messages for the sides and actions your strategy uses. The webhook URL is in the Setup panel on the same page.

Using a Pine Script strategy

  1. Select the Pinescript copy format in Hookmode. Copy the generated messages into your strategy and attach each to its corresponding entry or exit order.
  2. Create a TradingView alert for the strategy's order fills. Put the placeholder below in its Message field so each order sends its own instruction.
  3. In Notifications, enable Webhook URL and paste the URL copied from Hookmode.
Strategy alert message
{{strategy.order.alert_message}}
A strategy order-fill alert uses this placeholder to send each order's own opening or closing message. Expand Notifications to enter the webhook URL.

Recreate the alert after relevant script or setting changes. TradingView strategy alert instructions.

Using a regular indicator or price alert?

Use the JSON message for one action in the alert's Message field. If you copied a Pine Script variable, take only the JSON inside its quoted value. Leave out the variable name, equals sign, and surrounding single quotes.

Example buy opening message
{
  "webhook_id": "YOUR_WEBHOOK_ID",
  "signature": "YOUR_WEBHOOK_SIGNATURE",
  "side": "buy",
  "action": "open",
  "alert_id": "{{timenow}}"
}

This example shows the message shape. Use the ID and signature from your own webhook. Keep the matching buy/sell side and open/close action from the message Hookmode generated.

In Notifications, enable Webhook URL and paste the URL from Hookmode. A separate exit alert can send the matching closing message when your exit condition is met.

You need a TradingView plan with webhook access and two-factor authentication enabled. TradingView webhook requirements.

03

Choose how your trades close

You can let TradingView send both entry and exit instructions, or use TradingView for entries and let the configured stop loss and take profit handle exits.

Let TradingView trigger the close

  1. TradingViewEntry
  2. MT5Trade
  3. TradingViewExit

Close when an indicator changes, an opposite signal appears, or a Pine Script trailing stop is reached.

Enable Allow closing via webhook for the relevant buy or sell side, then connect its closing message to your exit signal.

Hookmode closes all open trades created by that webhook and side, across the accounts its rules cover.

Trailing logic runs in TradingView. Its signal closes the trade; it does not move a trailing stop in MetaTrader 5.

Close at stop loss or take profit

  1. TradingViewEntry
  2. MT5Trade
  3. BrokerSL / TP

Use TradingView for entries and set your stop-loss and take-profit distances in Hookmode.

Hookmode includes those levels when opening the trade in MetaTrader 5. Your broker handles the exit when a level is reached, and Hookmode records the close.

No closing alert from TradingView is needed.

A stop loss is required; take profit is optional. These broker levels also apply with TradingView closing alerts, so the broker may close a trade before a later exit signal arrives.

04

Follow your first trade

Let your configured alert trigger on demo. Check the alert in TradingView, its execution result in Hookmode, and the resulting position in MetaTrader 5.

  1. TradingView. The alert fired with the expected opening instruction.
  2. Hookmode. The signal record shows receipt, the matching rule, and the execution result.
  3. MetaTrader 5. Confirm the account, symbol, direction, volume, and protection levels.
  4. The close. Follow the TradingView exit signal or broker-side close through to the account history.
An example trace from a manual opening test. Use the same record to inspect the outcome of your TradingView signals.
Test the connection on demoUse the first-trade guide to send a manual test and read its execution trace, then observe an alert from TradingView.

Before continuing, you have observed both an entry and an exit through the path you chose. Receiving a signal alone does not confirm the trade filled.

Back to top