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.
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.
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.
Add a portfolio rule
Connect the webhook to your account. Check the broker's symbol and the resulting volume in lots before continuing.
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.
Using a Pine Script strategy
- Select the Pinescript copy format in Hookmode. Copy the generated messages into your strategy and attach each to its corresponding entry or exit order.
- 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.
- In Notifications, enable Webhook URL and paste the URL copied from Hookmode.
{{strategy.order.alert_message}}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.
{
"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.
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
- TradingViewEntry
- MT5Trade
- 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
- TradingViewEntry
- MT5Trade
- 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.
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.
- TradingView. The alert fired with the expected opening instruction.
- Hookmode. The signal record shows receipt, the matching rule, and the execution result.
- MetaTrader 5. Confirm the account, symbol, direction, volume, and protection levels.
- The close. Follow the TradingView exit signal or broker-side close through to the account history.
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.