Originally published on supa.is
OKX Signal Bot + TradingView: Automate Trades Without Code (2026 Step-by-Step)
I'd been manually copying trades from TradingView to OKX for weeks. See an alert, switch tabs, type the size, place the order. It worked — until it didn't. I missed a BTC breakout because I was in a meeting, and by the time I checked my phone the move was already 1.2% gone.
So I looked into automating it. The obvious path was API keys and webhooks — writing JSON, managing permissions, worrying about security. Then I found OKX's Signal Bot, which does all of that natively. No API keys to create. No code to write. OKX generates the webhook URL and the alert message format for you. You just paste them into TradingView.
I had my first automated trade running in about 15 minutes. But I also hit a configuration mistake that silently ate my first signal. This guide covers the exact process, including what went wrong so you can skip that part.
Disclosure: This article contains affiliate links. I may earn a commission if you sign up through my links, at no extra cost to you. I only recommend tools I actually use for my own trading.
What Is the OKX Signal Bot (and How Is It Different from Webhooks)?
If you've read about connecting OKX to TradingView, you know you can place manual trades from TradingView charts. And if you've explored webhook automation via API keys, you know that route involves managing credentials and writing JSON.
The Signal Bot is a third path — and for most people, it's the simplest:
| Feature | Chart Trading | Webhook + API | Signal Bot |
|---|---|---|---|
| Requires API keys? | No | Yes | No |
| Requires code? | No | Some JSON | No (copy-paste) |
| Automated execution? | No (manual) | Yes | Yes |
| Built-in position management? | No | You build it | Yes |
| TradingView plan needed? | Any | Essential+ | Essential+ |
| Risk isolation? | No | Sub-account optional | Per-bot investment |
The Signal Bot is essentially a managed trading bot that lives inside OKX. It listens for webhook signals from TradingView (or any external source) and executes trades within its own isolated margin. You fund the bot with a specific USDT amount, and it can't touch the rest of your account.
That isolation is the killer feature for me. Instead of giving API keys full trading access, the Signal Bot operates within a fixed budget that you control.
What You'll Need
Before starting:
- An OKX account with funds in your trading account (USDT for perpetual swaps)
- A TradingView paid plan — Essential or higher (webhooks require a paid plan)
- A TradingView strategy or indicator that generates alerts
- 15 minutes of setup time
Free TradingView Plus with OKX: If you trade $40,000+ in cumulative volume on OKX, you can unlock a free TradingView Plus subscription. Check the OKX × TradingView promo page for current details.
Step 1: Create a Custom Signal on OKX
First, you need to create a signal source that OKX will listen to. This generates a unique webhook URL and a signal token.
- Log in to OKX
- Navigate to Trade → Trading Bots → Marketplace
- Select the Signal Bot sub-tab
- Click Create
- Click Add custom signal
- Give your signal a name (e.g., "BTC MA Crossover TV") and optional description
- Click Create signal
OKX now shows you two critical pieces of information:
- Webhook URL — the endpoint TradingView will send alerts to
- Signal Token — your unique authentication key (embedded in the alert message)
Don't close this page yet. You'll need both values in the next step.
Step 2: Choose Your Alert Message Format
This is where people get confused. OKX offers two alert message formats:
Option A: TradingView Strategy Scripts (strategy.*() functions)
If your Pine Script uses strategy.entry(), strategy.exit(), or strategy.order(), use this format. OKX auto-generates a template that uses TradingView's strategy placeholders:
{
"id": "{{strategy.order.id}}",
"action": "{{strategy.order.action}}",
"marketPosition": "{{strategy.market_position}}",
"prevMarketPosition": "{{strategy.prev_market_position}}",
"instrument": "{{ticker}}",
"signalToken": "your-signal-token-here",
"timestamp": "{{timenow}}",
"maxLag": "60",
"investmentType": "base",
"amount": "{{strategy.order.contracts}}"
}
This is the easiest path. TradingView fills in all the {{placeholders}} automatically when the strategy triggers.
Option B: Custom Indicators or Manual Alerts
If you use an indicator (not a strategy) or set up alerts from the chart UI, you need to manually specify the action. OKX provides four templates:
Enter Long:
{
"action": "ENTER_LONG",
"instrument": "BTC-USDT-SWAP",
"signalToken": "your-signal-token-here",
"timestamp": "{{timenow}}",
"maxLag": "60",
"investmentType": "percentage_balance",
"amount": "10"
}
Exit Long:
{
"action": "EXIT_LONG",
"instrument": "BTC-USDT-SWAP",
"signalToken": "your-signal-token-here",
"timestamp": "{{timenow}}",
"maxLag": "60",
"investmentType": "percentage_position",
"amount": "100"
}
Replace ENTER_LONG / EXIT_LONG with ENTER_SHORT / EXIT_SHORT for short positions.
The investmentType Parameter (This Tripped Me Up)
The investmentType field determines how OKX interprets the amount:
| investmentType | What amount means |
When to use |
|---|---|---|
base |
Units of the base currency (e.g., 0.01 BTC) | Strategy scripts with {{strategy.order.contracts}}
|
margin |
USDT margin to allocate | Fixed dollar entries |
percentage_balance |
% of available bot balance | "Use 10% per trade" |
percentage_investment |
% of total bot investment | Relative to initial funding |
percentage_position |
% of open position to close | Exit signals |
My mistake: I used percentage_balance for entry signals but set amount to "100" thinking it meant "100 USDT." It actually means "100% of available balance" — the bot tried to go all-in on the first signal. Thankfully it was a small test bot. Read this table carefully.
Step 3: Set Up the Alert on TradingView
Now switch to TradingView:
- Open your chart with the strategy or indicator loaded
- Click the Alert button (clock icon in the right toolbar, or press Alt+A)
-
Set the Condition:
- For strategies: select your strategy name from the dropdown → "Order fills only"
- For indicators: select the indicator and the specific condition
- Paste the alert message from Step 2 into the "Message" field
-
Enable the Webhook URL:
- Under "Notifications," toggle on Webhook URL
- Paste the webhook URL from OKX (from Step 1)
- Set alert expiration — choose "Open-ended alert" if you want it to run indefinitely
- Click Create
Important: Make sure you select the correct perpetual swap contract on TradingView. For BTC, it should be
BTCUSDT.P(orBTCUSDTPERPdepending on your data feed). A mismatch between the TradingView ticker and the OKX instrument will silently fail.
Step 4: Create the Signal Bot
Back on OKX, you now attach your signal to a trading bot:
- After creating your signal, click Create Bot (or go to Trading Bots → Signal Bot → Create)
- Select your custom signal from the list
- Choose the trading pairs the bot will trade (e.g., BTC-USDT, ETH-USDT)
- Set leverage (1x–125x depending on the pair)
- Set investment amount — this is the USDT you allocate to this bot, isolated from the rest of your account
-
Configure entry settings:
- Order type: Market (recommended for signal trading) or Limit
- Take-profit / Stop-loss: Optional — you can let your TradingView strategy handle exits
- Review and click Create Bot
The bot is now live and listening for webhook signals.
Step 5: Test with a Real Signal
Don't just hope it works. Test it.
For strategy scripts: Switch to a short timeframe (1-minute chart), wait for your strategy to generate a signal, and check the bot's Event History.
For manual alerts: Create a one-time test alert with a small position size:
{
"action": "ENTER_LONG",
"instrument": "BTC-USDT-SWAP",
"signalToken": "your-signal-token-here",
"timestamp": "{{timenow}}",
"maxLag": "60",
"investmentType": "margin",
"amount": "5"
}
This opens a $5 USDT margin long position on BTC — small enough to be a harmless test.
How to Verify It Worked
- Go to Trading Bots → My Bots on OKX
- Click on your Signal Bot
- Check Event History — you should see the incoming signal and whether it was processed
- Check Positions — the trade should appear here
If the signal shows up in Event History but no trade executed, check:
- Is the trading pair added to the bot?
- Is there enough available balance in the bot?
- Does the instrument name match exactly? (
BTC-USDT-SWAP, notBTCUSDT)
Common Mistakes (and How to Fix Them)
Signal Received But No Trade
Cause: Instrument mismatch. TradingView sends BTCUSDT.P but OKX expects BTC-USDT-SWAP.
Fix: If you're using the {{ticker}} placeholder, OKX handles the translation automatically for strategy scripts. For custom alerts, use OKX's instrument format: BTC-USDT-SWAP, ETH-USDT-SWAP.
Alert Not Firing
Cause: TradingView alert expired or hit the alert limit for your plan.
Fix: Check your TradingView Alerts Log (clock icon → Alerts Log). Essential plan allows 20 active alerts; upgrade to Plus for 100.
maxLag Timeout
Cause: The maxLag parameter defaults to 60 seconds. If TradingView sends the alert late (network delay, high load), OKX rejects it.
Fix: Increase maxLag to "300" (5 minutes) for less time-sensitive strategies. Keep it at "60" for scalping.
Position Already Exists Error
Cause: The Signal Bot operates in one-way mode — it holds only one position direction per instrument at a time. If you send ENTER_LONG while already long, it may reject or add to the position depending on settings.
Fix: Always send an EXIT signal before reversing direction. For strategy scripts, TradingView handles this automatically through strategy.entry() which closes the opposite position first.
Signal Bot vs. Webhook API: Which Should You Use?
Both achieve automation, but they solve different problems:
Choose Signal Bot if:
- You want isolated risk management (bot has its own budget)
- You don't want to manage API keys
- You're running one strategy per bot
- You want built-in position tracking on OKX
Choose Webhook API if:
- You need to trade across multiple pairs dynamically
- You want full control over order types (limit, conditional, etc.)
- You're integrating with external systems beyond TradingView
- You need to manage multiple sub-accounts programmatically
For most TradingView users running a single strategy, the Signal Bot is the simpler, safer option. I use it for my momentum strategy setups — the isolation means a bad signal can't blow up my main account.
Advanced: Using Pine Script Strategy with Signal Bot
If you're comfortable with Pine Script, here's a minimal working strategy that sends proper signals to OKX Signal Bot:
//@version=6
strategy("MA Crossover Signal", overlay=true, default_qty_type=strategy.fixed, default_qty_value=0.001)
fast = ta.sma(close, 9)
slow = ta.sma(close, 21)
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long)
if ta.crossunder(fast, slow)
strategy.close("Long")
plot(fast, color=color.blue)
plot(slow, color=color.red)
When you create a TradingView alert on this strategy with the OKX-generated JSON template, the {{strategy.order.id}} placeholder automatically becomes "Long", {{strategy.order.action}} becomes "buy" or "sell", and the Signal Bot knows exactly what to do.
For a deeper dive into building real Pine Script strategies, see our Pine Script Moving Average Crossover tutorial and RSI Divergence Indicator guide.
FAQ
Can I use OKX Signal Bot with the free TradingView plan?
No. Webhooks — which Signal Bot relies on — require TradingView Essential or higher. Essential costs $12.95/month (billed annually). If you trade $40,000+ cumulative volume on OKX, you may qualify for a free TradingView Plus plan through the OKX partnership.
Does OKX Signal Bot work with spot trading or only perpetual swaps?
Currently, Signal Bot supports perpetual swap contracts only (e.g., BTC-USDT-SWAP). It does not support spot trading, margin trading, or futures with expiry dates. For spot orders, you'd need to use the webhook API approach with OKX connected to TradingView.
How many signals can an OKX Signal Bot handle?
Each signal can be connected to one bot. A single bot can trade multiple pairs (you add them during bot creation). You can create multiple bots, each with its own signal and isolated investment. This makes it easy to run several strategies in parallel without them interfering.
Is the OKX Signal Bot free to use?
Yes — OKX does not charge a fee for Signal Bot itself. You pay standard trading fees on the orders it executes, which depend on your OKX fee tier. New accounts using this referral link can get discounted trading fees.
What happens if TradingView goes down — does my position stay open?
Yes. The Signal Bot only acts when it receives a webhook. If TradingView can't send the alert (downtime, network issue), no action is taken. Your open position remains as-is. This is why I recommend setting a manual stop-loss on the bot as a safety net, regardless of your strategy's exit signals.
Bottom Line
OKX Signal Bot is the fastest path from "I have a TradingView strategy" to "it's trading automatically." No API keys, no code, no server — just two copy-paste values and a 15-minute setup.
The trade-off is flexibility. If you need complex order logic, multi-pair rotation, or integration with external data sources, you'll want the full API route. But for running a single Pine Script strategy with isolated risk, Signal Bot is hard to beat.
I've been running mine for a few weeks now. The signals fire, the bot executes, and I don't have to stare at charts during lunch anymore. That 1.2% BTC move I missed? With Signal Bot, I would have been in it.
Ready to set it up? Sign up on OKX to create your first Signal Bot, and grab a TradingView paid plan if you haven't already.
Risk Warning: Automated trading carries significant risk. Past performance of any strategy does not guarantee future results. Signal Bot executes trades based on your configured alerts — if your strategy generates bad signals, the bot will faithfully execute bad trades. Never automate with money you can't afford to lose. Start small, test thoroughly, and monitor your bot regularly.
Top comments (0)