What you'll build
By the end of this guide, you'll have three TradingView alerts wired to a single RelayDesk bot:
- An entry alert that opens a trade when your indicator fires a buy signal
- A partial exit alert that closes a portion of the position on a first target signal
- A full close alert that closes everything remaining when your indicator reverses
The example uses the UT Bot Alert indicator, one of the most popular TradingView scripts for trend-following entries and exits. The same pattern applies to any indicator, SuperTrend, Hull MA cross, custom Pine Script, the only thing that changes is which condition you attach each alert to.
Before you start
Make sure you have:
- A RelayDesk bot with Signal-Managed exit mode enabled and signal levels configured
- Your webhook token — found in the bot's Strategy or Connections section
- The UT Bot Alert indicator added to your TradingView chart (search for it in the Indicators library)
Your webhook URL will be:
https://app.relaydesk.io/api/signals/{your-webhook-token}Replace {your-webhook-token} with the token from your bot settings. Keep this URL handy. You'll paste it into each alert.
Example bot configuration
For this guide, the bot is configured with the following signal exit levels:
| Signal Name | Close % | Triggered by |
|-------------|---------|--------------|
| `tp1` | 50% | UT Bot sell signal (initial target) |A full close using the reserved exit keyword handles the final close.
This gives a two-stage exit:
- First UT Bot sell signal — close half the position, let the rest run
- Second UT Bot sell signal (or any reversal) — close everything remaining
You can adapt this to a single-exit setup (just use exit on the sell signal) or a three-stage setup with additional levels.
Step 1: Open the alert creation dialog
In TradingView, open your chart with the UT Bot Alert indicator applied.
Click the Alert button (clock icon) in the top toolbar, or press Alt + A.
Step 2: Create the entry alert
This alert fires when UT Bot prints a buy signal (green triangle/arrow on the chart).
Condition setup
In the Condition dropdowns:
- First dropdown: UT Bot Alert (the indicator name)
- Second dropdown: Buy (or the specific buy plot/condition from the indicator)
Trigger
Set to: Once Per Bar Close (recommended to avoid firing mid-candle)
Notifications tab
Enable Webhook URL and paste your RelayDesk webhook URL:
https://app.relaydesk.io/api/signals/{your-webhook-token}Message
Paste the following JSON exactly as written into the message field:
{
"action": "entry",
"direction": "long",
"symbol": "{{ticker}}"
}What each field does:
action: "entry": Tells RelayDesk to open a new tradedirection: "long": Buy calls (or puts if your bot is configured short)symbol: "{{ticker}}": TradingView auto-fills the chart ticker (e.g.,SPY)
Save the alert
Give it a name like UT Bot — Entry and click Create.
Step 3: Create the partial exit alert (TP1)
This alert fires on the first UT Bot sell signal, closing 50% of the position.
In the Condition dropdowns, set UT Bot Alert → Sell. Set the trigger to Once Per Bar Close and use the same webhook URL in the Notifications tab.
Message:
{
"action": "tp1"
}That's the entire payload. RelayDesk looks up tp1 in your bot's signal exit levels, finds the 50% close rule, and executes a market sell for half the remaining contracts. No symbol or direction is needed, RelayDesk already knows what's open for this bot.
Name the alert UT Bot — TP1 (50%).
Step 4: Create the full close alert
This alert fires on the second UT Bot sell signal (or whenever you want to close the remaining position entirely).
You have two options for how to set up the condition:
Option A — Same sell condition as TP1 Point this alert at the same UT Bot sell signal. After TP1 closes 50%, the next sell signal from UT Bot will close the remaining 50%. This gives you a clean two-signal exit on every trade.
Option B — A separate, stronger reversal condition If your strategy distinguishes between a "take some profit" signal and a "trend is definitely reversing" signal, attach this alert to the stronger condition. For example, a second indicator confirmation, a different timeframe sell, or a manual alert level.
Use the same webhook URL in the Notifications tab.
Message:
{
"action": "exit"
}exit is a reserved keyword in RelayDesk. It always closes 100% of the remaining position regardless of what signal levels are configured in the bot. No setup required.
Name the alert UT Bot — Full Close.
Step 5: Test on paper first
Before going live, run the setup in paper trading mode:
- Set your bot to Paper mode in RelayDesk
- Wait for UT Bot to fire a buy signal on your chart
- Confirm the trade appears in the Live Monitor
- Wait for (or manually trigger on a test chart) the sell signal
- Confirm the partial close executes and the trade card shows the updated contract count
- Confirm the full close executes and the trade shows as closed with a Signal Exit badge
Check the Signal History tab in your bot settings to see a log of every signal received and whether it executed, was skipped, or errored.
Your alert summary
Once all three alerts are created, your setup looks like this:
| Alert Name | Condition | Payload |
| --- | --- | --- |
| UT Bot — Entry | UT Bot Buy | `{ "action": "entry", "direction": "long", "symbol": "{{ticker}}" }` |
| UT Bot — TP1 (50%) | UT Bot Sell | `{ "action": "tp1" }` |
| UT Bot — Full Close | UT Bot Sell (or reversal) | `{ "action": "exit" }` |All three alerts use the same webhook URL.
Adapting this to other indicators
The structure is the same for any indicator. Here are a few common patterns:
SuperTrend: single exit on direction flip
{ "action": "entry", "direction": "long", "symbol": "{{ticker}}" }
{ "action": "exit" }Custom Pine Script: three-stage exit
{ "action": "entry", "direction": "long", "symbol": "{{ticker}}" }
{ "action": "tp1" }
{ "action": "tp2" }
{ "action": "exit" }Hull MA Cross: entry on cross up, close on cross down
{ "action": "entry", "direction": "long", "symbol": "{{ticker}}" }
{ "action": "exit" }Troubleshooting
Signal arrives but no trade opens
- Confirm the bot is active and in paper or live mode (not paused)
- Check that the
actionin your payload is exactly"entry"(lowercase) - Verify the webhook URL contains the correct token for this bot
- Check the Signal History tab in bot settings for a receive/reject log
Partial exit fires but closes the wrong amount
- Confirm the signal level name in your payload matches the name in bot settings exactly (e.g.,
tp1in the alert andtp1in the level config) - Check the close percentage configured for that level
exit or tp1 signal fires but nothing happens
- The most likely cause is no open trade. If the entry alert hasn't fired yet, or a previous trade fully closed already, exit signals are silently skipped.
- Check Live Monitor to confirm an open trade exists for this bot.
Two signals arrive close together and one seems to be missed
- RelayDesk serializes signals per trade. The second waits for the first fill to complete. If the first fill takes longer than expected (broker latency), the second will be delayed but will not be dropped. Check Signal History for execution timing.
TradingView shows the alert fired but RelayDesk didn't receive it
- Confirm Webhook URL is enabled in the alert's Notifications tab (it's easy to forget to check the checkbox)
- TradingView requires a paid plan (Pro or above) to use webhook alerts
Tips for a reliable setup
- Use "Once Per Bar Close" as your alert trigger. "Once Per Bar" can fire mid-candle on repaints, leading to premature entries or exits on some indicators.
- Name your alerts clearly — you'll manage these over time. Include the bot name and what the alert does:
SPY Bot — Entry,SPY Bot — TP1. - Test on a low-activity symbol first — paper trade on a slower-moving ticker to give yourself time to watch each step of the flow before going live on SPY or QQQ.
- Don't duplicate exit alerts — if both TP1 and Full Close are pointed at the same sell condition, they will fire at the same time. RelayDesk serializes them safely, but the second will find the position already closed (or heavily reduced) and adjust accordingly. If you want sequential exits on the same sell signal, use two separate alerts with the same condition — that's intentional and works correctly.
Congratulations! 🎉
You've completed this tutorial. Mark it as complete to track your progress.