Automating your trading strategy has never been easier. With the integration between OKX and TradingView, traders and signal providers can now seamlessly connect their technical analysis to live trading bots. This guide walks you through the complete process of setting up an OKX signal bot using TradingView alerts — whether you're using Pine Script™ strategies, indicators, chart-based analysis, or custom third-party tools.
By the end of this tutorial, you’ll be able to automate real-time trades based on your signals, manage risk with precision, and scale your crypto trading approach efficiently.
👉 Discover how automated trading can boost your strategy today.
Step 1: Access the Signal Bot on OKX
Log in to your OKX account and navigate to:
Trade → Trading Bots → Marketplace
From there, select the Signal Bot tab and click Create to begin setting up your automated trading system.
This opens the gateway for connecting external signals — particularly from TradingView — directly to your OKX trading engine.
Step 2: Create a New Signal
Click Add Custom Signal to start building your connection.
OKX simplifies the interface so you can quickly configure your TradingView alerts. Enter a signal name and optionally add a description (up to 500 characters). Once done, click Create Signal to proceed.
You’ll then see two critical pieces of information:
- The webhook URL
- The AlertMsg specification
These are essential for linking your TradingView alerts to OKX. Keep this page open — you'll need both elements in the next steps.
There are two ways to set up alerts:
- TradingView (Strategy): Best for users leveraging Pine Script™ strategies with
strategy.*()functions. - Custom (Indicator or External Tools): Ideal for those using indicators, chart patterns, or third-party programs.
Let’s explore both paths in detail.
Understanding Pine Script™: Strategy vs Indicator
Before diving into setup, it’s crucial to understand the difference between Pine Script™ strategies and indicators.
1. TradingView Strategy
Strategies in Pine Script™ are designed for backtesting historical data and forward-testing in live markets. They use strategy.*() functions to send simulated orders to Pine Script’s broker emulator. Results appear under the “Strategy Tester” tab below your chart.
If you're using a strategy script with strategy.entry(), strategy.close(), etc., use the TradingView strategy method.
2. TradingView Indicator
Indicators perform calculations but do not support backtesting or order simulation. Known as study scripts in Pine Script v4, they consume fewer resources and execute faster.
Use the Custom method if you’re working with:
- MACD, RSI, or other technical indicators
- Chart pattern alerts (e.g., price crossing a moving average)
- Third-party software sending signals
Now let’s walk through each configuration path.
Step 3.1: Setting Up a Pine Script™ Strategy
Ideal for users who trade with full strategy scripts.
Step 1: Configure Your Script
Open the Pine Editor on TradingView, set up your strategy, then click Save and Add to Chart.
Step 2: Adjust Strategy Settings
Click the gear icon next to your added strategy. Customize parameters like order size, then click OK.
How Order Size Translates to OKX
You can define position size in three ways on TradingView. Here’s how each maps to OKX:
1. Order Size in USDT
Enter a fixed amount in USDT (quote currency). For full compatibility with OKX:
{
"investmentType": "base",
"amount": "{{strategy.order.contracts}}"
}This ensures your OKX bot mirrors your TradingView position exactly.
2. Order Size in Contracts
Note: “Contract” means different things on TradingView vs OKX.
- TradingView: 1 BTC contract = 1 BTC
- OKX: 1 BTC-USDT-SWAP contract = 0.01 BTC
To align them:
- Use
"investmentType": "base" - Set
"amount": "{{strategy.order.contracts}}"
This matches base asset values directly.
3. Order Size as % of Capital
While possible, this method relies on simulated equity calculations during backtests, which may not reflect real performance. For accuracy, prefer USDT or contract-based sizing.
👉 Learn how professional traders size positions automatically.
Final Steps
- Click Create Alert on the toolbar.
- Set condition to "Order fills only".
- Choose "No expiration" for continuous monitoring.
- Paste the OKX alert template into the message field.
- Insert the webhook URL from OKX.
- Click Create.
⚠️ A paid TradingView subscription is required for webhook access.
Step 3.2: Using TradingView Indicators (Study Scripts)
For users relying on indicators like MACD, RSI, or custom alerts.
Step 1: Add Script to Chart
Set up your indicator in the Pine Editor and add it to the chart.
Step 2: Create Alert
Click Create Alert, choose the relevant alertcondition, e.g., “MACD Golden Cross”. Select "No expiration".
In the message box, paste the OKX-provided alert template (e.g., ENTER_LONG).
Important!
OKX supports four action types:
ENTER_LONGEXIT_LONGENTER_SHORTEXIT_SHORT
Choose the correct one based on your trading logic.
Step 3: Connect Webhook
Select Webhook as the alert action and paste your OKX webhook URL. Click Create.
Step 3.3: Chart-Based Analysis (No Pine Script)
For traders using built-in indicators or drawing tools.
Step 1: Create Alert
Click Create Alert, set a condition (e.g., “RSI(14) crosses above 30”), then paste the OKX AlertMsg JSON into the message field.
Ensure you use one of the four supported actions (ENTER_LONG, etc.).
Step 2: Add Webhook
Paste your OKX webhook URL and create the alert.
You can now view active alerts under the Alerts tab.
Step 3.4: Third-Party Programs (Python, APIs)
Signal providers using native apps can send alerts via HTTP POST requests.
Here’s a Python example:
import requests
import datetime
import json
signal_data = {
"action": "ENTER_LONG",
"instrument": "BTC-USDT-SWAP",
"signalToken": "your_token",
"timestamp": datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%fZ'),
"maxLag": "2000",
"investmentType": "percentage_balance",
"amount": "100"
}
response = requests.post('https://www.okx.com/join/BLOCKSTARalgo/signal/trigger', data=json.dumps(signal_data))🔐 If sending from a fixed IP, contact support at [email protected] to whitelist your address; otherwise, signals will be rejected.
Step 4: Configure Your Signal Bot
Back in OKX, click Create Bot.
Required settings:
- Trading pairs: Select symbols matching your strategy.
- Leverage: Choose your preferred level (e.g., 10x). Remember: higher leverage increases both profit potential and risk.
- Investment amount: Define total capital allocated to the bot.
Advanced Options:
- Order type: Market (instant execution) or Limit (price-specific).
- Per-order investment: Set fixed amounts (e.g., 500 USDT) or percentages (e.g., 10% of balance).
- Take Profit (TP) & Stop Loss (SL): Automate exits to lock profits and limit losses.
You can define these in the bot or receive them via alerts — offering full flexibility.
Click Confirm to activate your bot.
Step 5: Monitor and Manage Your Bot
Congratulations! Your signal bot is live.
From the bot dashboard, you can:
- View open positions and order history
- Track signal processing logs
- Manually adjust margin
- Place manual orders
- Close positions instantly
- Stop the bot anytime
Key Management Features:
- Adjust Margin: Add or reduce funds based on performance.
- Manual Orders: Open, increase, or close positions independently of signals.
- Instant Close: One-click exit all positions at market price.
- Stop Bot: Closes all positions and cancels pending orders. Access via bot info page or order tab.
Frequently Asked Questions (FAQ)
Q: Can I use free TradingView accounts for webhooks?
A: No. Webhook functionality requires a Pro or higher subscription on TradingView.
Q: What time zone does OKX use for timestamps?
A: All timestamps must be in UTC format (ISO 8601), e.g., 2025-04-05T12:30:00.000Z.
Q: Why are my signals not triggering trades?
A: Common causes include incorrect signalToken, invalid JSON format, expired alerts, or unwhitelisted third-party IPs.
Q: Can I use multiple signals for one bot?
A: Yes. As long as they share the same signalToken, multiple alerts can feed into a single bot.
Q: Is slippage controlled?
A: You can set orderPriceOffset in your alert to define acceptable deviation from market price.
Q: How often are signals processed?
A: Signals are processed in real-time upon receipt, subject to network latency and exchange conditions.
Core Keywords for SEO
- OKX signal bot
- TradingView webhook
- Automated crypto trading
- Pine Script strategy
- Connect TradingView to OKX
- Crypto trading bot setup
- Signal bot tutorial
- Algorithmic trading OKX
👉 Start automating your crypto trades with precision tools today.