---
url: /webhooks/tradingview-setup.md
description: >-
  Connect TradingView alerts to TTMT and have them trade through the same
  pipeline as Telegram signals — create a webhook, paste the JSON, verify the
  connection, and map your symbols.
---

# TradingView Webhook Setup

A TradingView webhook creates a **Synthetic Channel** in TTMT — one that behaves like a Telegram signal channel on every surface (Signal Log, Trade Log, Stats, presets) and runs through the same execution path: each alert is validated, safety-checked, routed to your active accounts, and executed by the adaptive order engine under your risk limits.

The difference is the source. Instead of a Telegram provider posting a message, you or your Pine script fires an HTTPS alert.

::: warning Early access
TradingView webhooks are enabled per user by the TTMT team. Without access, the **TradingView webhooks** tab on the Connectors page shows **Early access** with a **Join early access** button instead of a webhook list. Use it, or contact support, to request access.
:::

::: warning Start on a demo account
This is the only connector that places real trades. Start on a demo account. Every account a webhook trades on needs a default stop loss that always applies, or alerts are refused. While webhooks are limited to demo accounts, the page tells you so.
:::

## Creating a webhook

Open **Connectors** in the sidebar, choose **TradingView webhooks**, and click **New webhook**. A dialog opens (a sheet on a phone).

1. **Name it.** The name becomes the channel name in your Signal Log and Trade Log.
2. **Pick the accounts.** Under **Trades on**, choose which of your MetaTrader accounts receive its alerts. With several accounts, each one gets its own switch, the same broadcast pattern as every other channel.
3. Click **Create webhook**.

The webhook opens with four setup steps. Creating it sets it to **Pending verification**: no alerts trade until you finish step 4.

### The four setup steps

1. **Copy the webhook URL.** It is not secret, and you can copy it again from this page at any time.
2. **In TradingView, open the alert, go to Notifications, and paste the URL into Webhook URL.** The **Open TradingView** button opens the chart in a new tab. You need a TradingView plan with webhooks and two-factor sign-in turned on in TradingView.
3. **Copy the alert message and paste it into the alert's Message box.** The message already contains your secret. **This is the only time the full secret appears.** Use **Copy alert message** or **Copy all (URL, secret and message)**, tick **I've pasted it into TradingView**, then use **Hide the secret**. If you leave the page without copying it, use **Rotate secret...** to get a new one. Rotation invalidates the previous secret immediately. A collapsible **What the placeholders mean** explains each field.
4. **Save the alert, then press Test in TradingView.** The page shows *"Waiting for a test alert. You can leave this page; come back here to confirm."* When TTMT receives the test, it reads *"Test alert received: BUY XAUUSD"* (with your own direction and symbol). If the ticker has no mapping yet, a **Map symbol** button offers to add it. Then click **Confirm & activate**. A toast confirms *"Webhook is live."* and from this point on, alerts trade.

Inbound alerts while the webhook is **Pending verification** are logged but place no trade. If step 4 never completes, a **Not arriving?** checklist on the page covers the usual causes: a trailing space in the URL, invalid JSON or a wrong secret, TradingView giving up after 3 seconds, or not pressing Test.

### Managing a webhook

On the webhook's detail page:

* **Take new alerts** is the pause switch (shown once the webhook is active). On: alerts open trades. Off: new alerts are refused.
* **Trades on** lists its accounts, each with its own switch.
* **Secret** shows the masked secret, with **Rotate secret...**.
* **Revoke...** stops the webhook for good. The channel and its trade history stay.
* The **Symbols** section is the webhook's TradingView-ticker map (see [Webhook symbol map](#webhook-symbol-map) below).
* A webhook that hit its limits shows an amber notice with the reason it was paused automatically.

The channel's **Webhook tab** (`?tab=webhook`) keeps the delivery log, the secret rotation, **Confirm & activate**, and a **Symbol Map** button, so you can finish or manage a webhook from either place.

## The JSON payload

Paste this JSON into the **Message** box when creating a TradingView alert:

```json
{
  "secret":    "ttmt_hook_REPLACE_WITH_YOUR_WEBHOOK_SECRET",
  "action":    "BUY",
  "symbol":    "{{ticker}}",
  "timeframe": "{{interval}}",
  "bar_time":  "{{time}}",
  "price":     {{close}},
  "strategy":  "My Strategy Name",
  "client_id": "{{ticker}}_{{interval}}_{{time}}"
}
```

For a SELL alert, change `"action": "BUY"` to `"action": "SELL"`.

Replace `ttmt_hook_REPLACE_WITH_YOUR_WEBHOOK_SECRET` with the secret you copied in step 3. The message the Connectors page hands you is shorter (action, symbol, timeframe, bar\_time, price and secret). It uses {{strategy.order.action}} for the direction, which works for strategy alerts. For an indicator or price alert, replace it with `buy` or `sell`. The `strategy` and `client_id` fields here are optional, and the app's message sends `price` as a quoted "{{close}}".

::: tip Only `secret`, `action`, and `symbol` do real work
TTMT uses your alert to know **which way to trade** (`action`) and **what instrument** (`symbol`), authenticated by your `secret`. The `bar_time`, `timeframe`, `price`, `strategy`, and `client_id` fields are optional payload metadata — they help TTMT de-duplicate repeated alerts and enrich your logs, but none of them set your entry, stop, or targets. Those come from your account and preset defaults (see [SL/TP defaults](#sl-tp-defaults-required) below).
:::

::: info The `price` field is optional metadata, not your entry
The template keeps {{close}} unquoted so `price` arrives as a JSON number, which is the tidiest form. A quoted numeric string (for example `"2345.67"`) is also accepted — TTMT reads `price` as a number or a numeric string. Either way, `price` is only recorded for your logs. It is **not** the price TTMT enters at, and it does not influence how your prices are checked; TTMT opens a market or limit order from the live broker price and your account's SL/TP defaults.
:::

## Placeholder cheat-sheet

| Placeholder | What it becomes | Notes |
|---|---|---|
| {{ticker}} | Symbol on your chart, e.g. `OANDA:XAUUSD` | Required (via `symbol`) |
| {{interval}} | Chart timeframe, e.g. `60` for 1-hour | Optional; feeds the de-dupe key |
| {{time}} | Bar open timestamp in milliseconds | Optional but strongly recommended — see below |
| {{close}} | Bar close price — unquoted number | Optional log metadata; not the entry price |
| {{strategy.order.alert\_message}} | Per-order action from `strategy.entry(alert_message=...)` | Strategy path only |
| {{strategy.order.id}} | Order ID — appended to `client_id` for multi-order bars | Strategy path only |

**Why `bar_time` is strongly recommended.** `bar_time` is not required, but you should send it. TTMT uses it to de-duplicate repeated alerts for the same bar and to judge whether an alert is fresh enough to act on (see the [15-minute freshness guard](#the-15-minute-freshness-guard) below). Without it, TTMT falls back to weaker de-duplication, so a chart that re-fires the same bar can open a second trade.

The `price` value is recorded as log metadata only. TTMT does **not** use the bar close as your trade entry price, and it does not feed the price checks that screen for bad values — it opens a market or limit order based on the live broker price and your account's SL/TP defaults.

## Pine script paths

The TTMT webhook reference indicator (`ttmt-webhook.pine`) shows three ways to fire alerts. Choose the path that fits your setup.

### Path 1 — `alertcondition` (shared / published indicator)

**When to use:** you are publishing the indicator or sharing it with others and cannot embed a secret in the script.

The JSON lives in TradingView's **Message box**, not in the Pine source. The {{...}} placeholders substitute at alert-fire time in the Message box and in `alertcondition(message=...)` — they do **not** substitute inside `alert()` string arguments.

Steps:

1. Add the TTMT indicator to your chart.
2. Open **Create Alert** (Alt+A).
3. Set the Condition to the indicator's BUY or SELL condition.
4. Paste the JSON template into the **Message** box and replace the placeholder secret with your real `ttmt_hook_` secret.
5. Enter your webhook URL in the **Webhook URL** field and save.

### Path 2 — `alert()` (private / unpublished copy)

**When to use:** you keep the script private and prefer the secret to live in the script's input field rather than the alert Message box.

Fork the reference indicator and keep it **unpublished**. Enter your real `ttmt_hook_` secret in the **Webhook Secret** input field inside the script. The JSON is assembled from Pine built-ins at bar close using `str.tostring()` concatenation, and `alert()` fires with `freq_once_per_bar_close` — once per confirmed bar, no tick noise.

::: danger Keep the script unpublished
A Pine script with a real `ttmt_hook_` secret in an input field must remain private/unpublished. If the script is shared or published, the secret is exposed and anyone could fire trades against your account.
:::

### Path 3 — strategy

**When to use:** a `strategy()` script where you want {{strategy.order.alert\_message}} to carry the direction and {{strategy.order.id}} to disambiguate multiple orders on the same bar.

In the strategy alert's Message box (Order Fills section), use:

```json
{
  "secret":    "ttmt_hook_REPLACE_WITH_YOUR_WEBHOOK_SECRET",
  "action":    "{{strategy.order.alert_message}}",
  "symbol":    "{{ticker}}",
  "timeframe": "{{interval}}",
  "bar_time":  "{{time}}",
  "price":     {{close}},
  "strategy":  "My Strategy Name",
  "client_id": "{{ticker}}_{{interval}}_{{time}}_{{strategy.order.id}}"
}
```

Set `alert_message="BUY"` or `alert_message="SELL"` on your `strategy.entry()` calls so {{strategy.order.alert\_message}} carries the right direction.

::: danger Today, strategy exits open new trades — they do not close positions
Every webhook alert is an independent **new trade** signal. There is currently no close or reverse alert type, and an alert never carries entry, stop, or take-profit levels into the trade — every alert opens a fresh trade using your account and preset defaults.

Do **not** wire `strategy.exit()` or `strategy.close()` alerts to your TTMT webhook expecting them to flatten an open position. Today they arrive as new-trade signals and will attempt to **open** a position in that direction. Wire BUY and SELL entry alerts only.

Close and reverse handling from a webhook alert is on the roadmap but is **not committed** — don't build a strategy that depends on it yet.
:::

## Webhook symbol map {#webhook-symbol-map}

TradingView tickers include exchange prefixes (`OANDA:XAUUSD`, `BINANCE:BTCUSDT`) that don't match broker symbols. You must map each TV ticker to its broker symbol manually.

This map is about TradingView tickers. It is not the broker-symbol list in Settings › Symbol mappings. Open the webhook's **Symbols** section under Connectors › TradingView webhooks, or the **Symbol Map** button on the channel's **Webhook tab**; both open the same editor. Add a row for each ticker your strategy sends:

| TV ticker | Broker symbol |
|---|---|
| `OANDA:XAUUSD` | `XAUUSD` |
| `BINANCE:BTCUSDT` | `BTCUSD` |
| `PEPPERSTONE:EURUSD` | `EURUSD` |

**If no mapping exists for an incoming ticker, the alert is rejected.** No trade is placed. The rejection appears in the alert log with reason `unmapped_symbol` and shows you the exact ticker string TTMT received.

::: tip Map the ticker during setup
During setup step 4 the test alert reads *Test alert received: BUY XAUUSD*, and if the ticker has no mapping a **Map symbol** button offers to add it, so you can map it before the webhook goes live. An `unmapped_symbol` rejection in the alert log also links to the symbol map.
:::

## SL/TP defaults — required {#sl-tp-defaults-required}

Webhook alerts carry only a direction (`BUY`/`SELL`) and a symbol — no stop-loss or take-profit levels. TTMT builds the trade's stop and targets from your configured defaults.

Because a webhook trade has no stop of its own, TTMT enforces a **stop-loss safety guard**: it will not let a webhook alert trade any account that isn't set up to receive a stop. For every account assigned to the webhook, that account's effective settings must have the stop override on (Settings › Stop loss › **Always use my stop, not the signal's**) and a non-zero default stop loss (**Stop loss when the signal has none**).

::: warning Every assigned account must be armed — one unarmed account blocks the whole alert
The guard checks *all* of the webhook's active accounts. If even one assigned account is missing its SL override or has a zero default SL, the alert is rejected with reason `webhook_zero_sl_guard` and **no** account trades it. Arm every account before you go live.
:::

To arm an account, turn on **Always use my stop, not the signal's** and set a non-zero **Stop loss when the signal has none**, both in Settings › Stop loss, either as the account default or in a preset you give the channel. See [Override modes](/core-concepts/override-modes) for how the SL override works.

**Take-profit behavior is separate and is not enforced the same way.** Your default take-profit targets (and TP behavior) are applied from your settings as a recommendation — TTMT does not block an alert for lack of a TP the way it does for a missing stop. The stop is the hard safety requirement; the targets follow your normal TP configuration.

## Delivery log

Every inbound alert — whether it traded or not — is recorded. On Connectors › TradingView webhooks it appears under **Alerts received** (the latest 50), with an outcome chip: **Accepted**, **Rejected**, **Duplicate**, **Test alert**, **Service unreachable** or **Unknown**. **Details** shows the reason code. For some rejections the row links to the fix, for example **Turn on Always use my stop loss** and **Set the default stop loss** for a stop-loss guard rejection. The channel's Webhook tab keeps an older delivery log with the status codes below. Check here first when diagnosing issues.

| Status | Chip in Alerts received | What happened |
|---|---|---|
| `verification_ping` | Test alert | Alert received while pending verification — no trade was placed |
| `signal_created` | Accepted | Alert processed successfully — a signal and trade were created |
| `deduped` | Duplicate | Duplicate alert for the same bar (same `client_id` / `bar_time`) — ignored |
| `rejected` | Rejected | Alert rejected before any trade — see the **reason** column |
| `circuit_open` | Rejected | Per-minute or per-day cap was hit — webhook auto-paused |
| `container_down` | Service unreachable | Trading instance was unreachable — TradingView may retry the alert |
| `failed` | Unknown | Processing error, outcome not known — check the Signal Log, and contact support if this persists |

### Rejection reasons

| Reason | Fix |
|---|---|
| `unmapped_symbol` | Add the TV ticker shown in the log to your symbol map |
| `webhook_zero_sl_guard` | Turn on **Always use my stop, not the signal's** and set a default stop loss on every account of this webhook |
| `no_active_assignment` | Assign at least one account to this webhook |
| `webhook_paused` | Webhook is paused — turn **Take new alerts** back on in Connectors › TradingView webhooks |
| `stale_alert` | Alert's `bar_time` was more than 15 minutes old — see the freshness guard below |

### Circuit breaker defaults

| Limit | Default |
|---|---|
| Alerts per minute | 60 |
| Trades per day | 50 |

Both limits apply per webhook. If either cap is breached, the webhook auto-pauses and you receive a notification. Turn **Take new alerts** back on in Connectors › TradingView webhooks. Contact support if your strategy legitimately needs higher limits.

## The 15-minute freshness guard {#the-15-minute-freshness-guard}

TTMT will not act on a stale alert. If an alert's `bar_time` is **more than 15 minutes old** by the time it arrives, TTMT skips it and records `stale_alert` in the delivery log — no trade is placed.

This guard protects you from acting on late deliveries: a queued retry, a delayed alert, or a burst of backlogged alerts that arrive long after the bar they describe. Trading a signal that's a quarter-hour stale usually means chasing a move that has already happened.

::: tip Send `bar_time` and use bar-close alerts
The freshness check reads `bar_time`, so include {{time}} in your payload (the templates above already do). Firing alerts on bar close — as the `alert()` path does with `freq_once_per_bar_close` — keeps the timestamp accurate and well inside the window. If you see `stale_alert` rejections on alerts that fired on time, check for a large clock skew or a retry backlog in TradingView's alert history.
:::

## Troubleshooting checklist

**No entries in the delivery log at all**
Check that your TradingView alert is enabled (not expired), the Webhook URL is pasted correctly without trailing spaces, and the alert condition is actually firing.

**`400` in TradingView's alert history**
Your JSON is malformed. Validate it with a JSON linter. Common causes are a stray trailing comma, an unescaped quote in your `strategy` name, or a missing brace. (A quoted numeric `price` is *not* a cause — TTMT accepts `price` as a number or a numeric string.)

**`401 Unauthorized` in the delivery log**
The `"secret"` value in your alert Message doesn't match your webhook secret, or the secret has been rotated. Check the value on the Webhook tab and rotate if it has been lost.

**`unmapped_symbol` rejections**
Open the Symbols section (or the Symbol Map button) and add the exact ticker string shown in the delivery log.

**`webhook_zero_sl_guard` rejections**
At least one account assigned to this webhook has no stop-loss safety configured. Arm **every** assigned account — turn on **Always use my stop, not the signal's** and set a non-zero **Stop loss when the signal has none** in Settings › Stop loss, or in a preset. One unarmed account blocks the alert for all of them.

**`stale_alert` rejections**
The alert's `bar_time` was more than 15 minutes old when it reached TTMT. Fire alerts on bar close, include {{time}} in the payload, and check TradingView's alert history for a retry backlog. See [the freshness guard](#the-15-minute-freshness-guard).

**Webhook stuck at Pending verification**
If you see `verification_ping` entries in the delivery log but the webhook hasn't activated, click **Confirm & activate** in setup step 4 on the webhook page, or from the channel's Webhook tab.

**Webhook auto-paused (`circuit_open`)**
Turn **Take new alerts** back on. If your strategy fires more than 60 alerts per minute or more than 50 trades per day legitimately, contact support to adjust the caps.
