Integrating automated trading strategies with real-time execution has never been easier. With the launch of signal bots, OKX now enables traders and signal providers to publish and configure custom TradingView signals directly into live trading bots. Whether you're a beginner or an experienced trader, this comprehensive guide walks you through every step of setting up a TradingView signal bot on OKX, ensuring seamless connectivity, accurate trade execution, and full control over your strategy.
By the end of this article, you’ll understand how to link your Pine Script™ strategies or indicators to OKX, configure webhooks, manage risk settings, and monitor bot performance—all in real time.
👉 Discover how to turn your TradingView signals into automated trades today.
Step 1: Access the Signal Bot Feature
To begin, log in to your OKX account and navigate to:
Trade → Trading Bots → Marketplace
Once there, select the Signal Bot tab and click Create to start building your bot.
This section serves as the central hub for managing all your signal-based trading activities. From here, you can create new bots, view active ones, and monitor their performance across multiple markets.
Step 2: Create Your Custom Signal
Click on Add Custom Signal to initiate the setup process. You’ll be prompted to:
- Name your signal (required)
- Add an optional description (up to 500 characters)
After completing these fields, click Create Signal to proceed.
You'll then be directed to a new page displaying two critical pieces of information:
- Webhook URL: This unique link connects TradingView alerts to OKX.
- AlertMsg Specification: A JSON template that defines how signals are formatted when sent from TradingView.
Keep this page open—you'll need both the webhook URL and the correct message structure when setting up alerts in TradingView.
Understanding Signal Configuration Options
OKX supports two primary methods for configuring trading signals:
- TradingView (Strategy Mode): Best for users leveraging Pine Script™ strategy functions like
strategy.entry()orstrategy.close(). Ideal for backtested automated strategies. - Custom (Indicator or Third-Party Tools): Designed for traders using standard indicators (e.g., RSI, MACD), chart-based conditions, or external programs such as Python scripts.
Choose the method that aligns with your current workflow.
Pine Script™ Quick Reference: Strategy vs. Indicator
Understanding the difference between Pine Script strategies and indicators is essential for proper integration.
1. TradingView Strategy Scripts
Pine Script™ strategies allow backtesting on historical data and real-time simulation using the strategy tester. These scripts use built-in functions like strategy.entry(), strategy.exit(), and strategy.close() to generate trade orders within the Pine Script™ broker emulator.
Results appear in the Strategy Tester tab, located beneath the chart interface. If you're using any strategy.*() functions, always use the TradingView configuration mode during setup.
2. TradingView Indicator Scripts
Indicators (also known as "studies" in Pine Script v4+) perform technical calculations but do not support order execution or backtesting natively. They are lightweight and fast, making them ideal for real-time alert generation.
If you’re using indicator-based alerts—such as MACD crossovers or RSI thresholds—or third-party tools, choose the Custom configuration option.
👉 Automate your favorite indicator signals with just a few clicks.
Step 3: Configure TradingView Alerts
Open TradingView.com, select the desired trading pair (ensure it matches a supported perpetual swap on OKX), and follow one of the paths below based on your script type.
Step 3.1: Guide for Pine Script™ Strategy Users
Set Up Your Strategy Script
- Open the Pine Editor.
- Save and add your strategy script to the chart.
Adjust Strategy Settings
- Click the gear icon next to the added strategy.
- Customize parameters such as order size, initial capital, and pyramiding settings.
- Confirm with OK.
Matching Order Size Settings with OKX
Ensure compatibility between TradingView and OKX by correctly mapping order values:
Option 1: Order Size in USDT
Directly input fixed amounts in USDT. For OKX compatibility:
- Set
"investmentType": "base" - Use
"amount": "{{strategy.order.contracts}}"
This ensures precise alignment between simulated and live trades.
{
"id": "{{strategy.order.id}}",
"action": "{{strategy.order.action}}",
"instrument": "{{ticker}}",
"signalToken": "your_token_here",
"timestamp": "{{timenow}}",
"maxLag": "60",
"investmentType": "base",
"amount": "{{strategy.order.contracts}}"
}Option 2: Order Size in Contracts
Note: Contract definitions differ between platforms. In TradingView, one contract equals one unit of base asset (e.g., 1 BTC). On OKX, BTC-USDT-SWAP uses 0.01 BTC per contract.
To maintain consistency:
- Use
"investmentType": "base" - Map
"amount": "{{strategy.order.contracts}}"
Option 3: Order Size as % of Equity
While possible, equity-based sizing relies heavily on backtest calculations, which may not reflect live performance accurately. For more reliable results, consider using fixed USDT or contract amounts instead.
Create the Alert
- Click Alerts > + New Alert
- Set condition to your strategy with “Order Filled” trigger
- Choose “One-time alert” or “Ongoing alert” based on preference
Configure Message & Webhook
- Paste the OKX AlertMsg JSON template into the message field
- Replace
signalTokenwith your actual token - Under notifications, select Webhook URL
- Paste the webhook URL copied from OKX
- Click Create
⚠️ Note: A paid TradingView plan is required to access webhook functionality.
Step 3.2: Guide for Indicator / Study Script Users
- Save and apply your Pine Script indicator to the chart.
- Click Alerts > + New Alert
- Select your indicator and set the appropriate
alertcondition()(e.g., “MACD Golden Cross”) - Insert the OKX AlertMsg JSON template into the message box
- Select Webhook URL, paste your OKX webhook, and create the alert
✅ Important: OKX supports four key actions:
ENTER_LONGEXIT_LONGENTER_SHORTEXIT_SHORT
Ensure each alert uses the correct action based on your trading logic.
Step 3.3: Guide for Chart Pattern & Basic Indicator Users
You don’t need Pine Script at all—set up alerts directly from chart patterns or built-in indicators:
- Click Alerts > + New Alert
- Define condition (e.g., “RSI(14) crosses above 30”)
- Paste the appropriate OKX AlertMsg format into the message field
- Add your webhook URL under notifications
- Create the alert
This method works seamlessly with any visual or rule-based trading approach.
Step 3.4: Guide for Third-Party Software Providers
Advanced users sending signals via Python, Node.js, or other systems can integrate directly using HTTP POST requests.
Here’s a sample Python script:
import datetime
import requests
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": "50"
}
response = requests.post('https://www.okx.com/join/8265080algo/signal/trigger', data=json.dumps(signal_data))🔐 If sending from a fixed IP address, contact OKX customer support to whitelist your endpoint and prevent signal rejection.
Step 4: Configure Your Signal Bot
Now that your signal is live in TradingView, return to OKX and click Create Bot.
Complete the following:
- Trading Pairs: Enter symbols matching your strategy (e.g., BTC-USDT-SWAP)
- Leverage Ratio: Choose based on risk tolerance (e.g., 5x, 10x)
- Margin Amount: Allocate funds you're willing to commit
Then customize advanced options:
- Order Type: Market (instant execution) or Limit (price-controlled)
- Investment per Order: Define as fixed amount (e.g., 200 USDT) or percentage (e.g., 10% of balance)
- Take Profit (TP) & Stop Loss (SL): Automatically lock in gains or limit losses
- Source priority: Use bot-level defaults or accept dynamic values from TradingView alerts
Click Confirm to activate your bot.
Step 5: Monitor and Manage Your Signal Bot
Congratulations—you’ve successfully launched a fully automated trading bot powered by TradingView signals!
Access detailed insights via the Bot Details panel, where you can:
- View performance history
- Track open positions and pending orders
- Analyze signal logs and execution accuracy
- Manually adjust margin or override trades if needed
Key Management Features
- Adjust Bot Margin: Add or remove funds anytime.
- Manual Orders: Place trades outside signal input.
- Close Positions Instantly: Exit any open trade with one click.
- Stop the Bot: Close all positions and cancel pending orders safely.
Stopping methods:
- From Bot Details → Click Stop
- From Trade Page → Bot Orders Tab
Frequently Asked Questions (FAQ)
Q: Can I use free TradingView accounts with OKX signal bots?
A: No. Webhook alerts require a Pro or higher subscription on TradingView.
Q: What happens if a signal is delayed or missed?
A: The system includes a maxLag parameter (in seconds). Signals arriving later than this window are rejected to ensure freshness.
Q: Can I run multiple bots with different strategies?
A: Yes. Create separate bots for each unique signal source or trading logic.
Q: Is leverage applied automatically?
A: Leverage must be manually set during bot creation and can be adjusted later.
Q: How do I verify my signal is working?
A: Check the Signal Log in Bot Details. Each received alert will show timestamp, action, and execution status.
Q: Are futures and spot markets supported?
A: Currently, only perpetual swap contracts are supported for signal bot integration.
Final Thoughts
Setting up a TradingView signal bot on OKX bridges powerful technical analysis with automated execution—giving you speed, precision, and peace of mind.
Whether you're using simple indicator crossovers or complex algorithmic strategies, this integration empowers you to trade smarter, not harder.
👉 Start automating your trading strategy with confidence—connect your signals now.
With robust customization, real-time monitoring, and flexible risk controls, OKX’s signal bot feature is a game-changer for modern crypto traders aiming for consistent performance in volatile markets.