Automating your trading strategy has never been easier. With the integration between OKX Signal Bots and TradingView, traders can now seamlessly connect their custom signals to execute real-time trades on the OKX exchange. Whether you're using Pine Script™ strategies, indicators, chart-based analysis, or third-party tools, this guide walks you through every step of setting up a fully functional Signal Bot—no coding expertise required.
This comprehensive walkthrough ensures clarity, accuracy, and alignment with both platforms’ technical requirements. By the end, you'll have a robust system that listens for signals and executes trades automatically, giving you a competitive edge in fast-moving crypto markets.
Step 1: Access the Signal Bot Dashboard
Begin by logging into your OKX account. Once inside:
- Navigate to Trade > Trading Bots > Marketplace.
- Click on the Signal Bot sub-tab.
- Select Create to begin setting up your signal.
This opens the gateway to connecting your TradingView-generated signals with live trading actions on OKX.
👉 Start building your automated trading strategy today with powerful tools on OKX.
Step 2: Create Your Custom Signal
Click Add Custom Signal to initiate the setup.
You’ll be prompted to:
- Name your signal (e.g., “MACD Momentum Strategy”).
- Add an optional description (up to 500 characters).
After clicking Create Signal, OKX will generate two critical components:
- A unique Webhook URL
- An Alert Message Template
These are essential for linking TradingView alerts to OKX execution. Keep this page open—you’ll need both pieces in the next steps.
Understanding Pine Script™: Strategy vs Indicator
Before configuring alerts, it’s important to understand which type of script you're working with:
TradingView Strategy Scripts
Strategies use strategy.*() functions and support backtesting via the Strategy Tester. They simulate trade entries, exits, and performance over historical data.
If you’re using a strategy script, proceed to Step 3.1.
TradingView Indicator (or Study) Scripts
Indicators perform calculations but do not simulate trades or manage positions. They’re faster and more resource-efficient than strategies.
If you’re using an indicator or study script—or rely on manual chart patterns—proceed to Step 3.2 or 3.3.
Step 3: Configure Alerts in TradingView
Now switch to TradingView.com and prepare your alert based on your signal type.
Step 3.1: For Pine Script™ Strategy Users
- Open the Pine Editor, configure your strategy, then click Save and Add to Chart.
- Click the gear icon next to the applied strategy to adjust order size, initial capital, or other parameters.
- Click the Alert button at the top toolbar.
- Set the condition to your strategy with "Order fills only" selected.
- Choose Open-ended alert for continuous monitoring.
Aligning Order Size with OKX
Your order size must be properly mapped so OKX interprets it correctly:
| Order Type | OKX Configuration |
|---|---|
| USDT Amount | "investmentType": "base", "amount": "{{strategy.order.contracts}}" |
| Contracts | Same as above — contracts in TradingView equals base currency units |
| % of Equity | Use caution—backtest equity ≠ live balance; prefer fixed USDT or contract sizes |
Paste the following JSON structure into the Message field (replace placeholders):
{
"id": "{{strategy.order.id}}",
"action": "{{strategy.order.action}}",
"marketPosition": "{{strategy.market_position}}",
"prevMarketPosition": "{{strategy.prev_market_position}}",
"instrument": "{{ticker}}",
"signalToken": "YOUR_SIGNAL_TOKEN",
"timestamp": "{{timenow}}",
"maxLag": "60",
"investmentType": "base",
"amount": "{{strategy.order.contracts}}"
}Finally, under Notifications, paste your Webhook URL from OKX and click Create.
🔐 Note: A paid TradingView plan is required to access Webhook alerts.
Step 3.2: For Indicator or Study Script Users
- Add your Pine Script™ indicator (e.g., RSI, MACD) to the chart.
- Click Alert, set condition (e.g.,
MACD Golden Cross), and choose Open-ended. - In the Message box, paste the template from the Custom tab in OKX’s Alert Message Specifications.
- Select the correct action (
ENTER_LONG,EXIT_SHORT, etc.) based on your logic. - Paste the Webhook URL under Notifications and click Create.
Ensure you pick the right message template corresponding to each trade action.
Step 3.3: For Chart-Based Analysis Users
No scripts? No problem.
- Click Alert, set a visual or technical condition (e.g., “RSI crosses above 30”).
- Paste the appropriate OKX alert message template.
- Choose correct action type (
ENTER_LONG, etc.). - Add Webhook URL and create the alert.
This method works perfectly for traders who rely on support/resistance levels, trendlines, or multi-indicator confluences.
Step 3.4: For Third-Party Program Users (e.g., Python)
Advanced users can send signals directly from external programs like Python.
Example POST request:
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))📌 Important: If sending from a fixed IP, contact OKX customer service to whitelist your address—otherwise, signals may be rejected.
Step 4: Set Up Your Signal Bot
Return to OKX and click Create Bot.
Configure these key settings:
- Trading Pairs: Select one or more perpetual swap pairs (e.g., BTC-USDT-SWAP).
- Leverage: Choose a ratio (e.g., 10x). Higher leverage increases risk and reward.
- Margin: Define how much capital to allocate to the bot.
Advanced Settings
- Order Type: Market (instant execution) or Limit (price-controlled).
- Entry Settings: Set investment per trade as fixed amount (e.g., 500 USDT) or percentage (e.g., 10% of balance).
- Exit Settings: Define Take Profit (TP) and Stop Loss (SL) levels.
- Parameter Source: Decide whether values come from TradingView alerts or are fixed in bot settings.
Once configured, click Confirm to activate your bot.
👉 Maximize your trading efficiency—automate signals with precision on OKX.
Step 5: Monitor and Manage Your Bot
Your Signal Bot is now live—listening for incoming signals and executing trades in real time.
From the Bot Details page, you can:
1. Adjust Margin
Add or remove funds anytime to scale your exposure or lock in profits.
2. Place Manual Orders
Override automation when needed: open, increase, or reduce positions manually.
3. Close Open Positions Instantly
One-click closure of any active trade at market price.
4. Stop the Bot
Stopping closes all open positions and cancels pending orders. Assets return to your main account.
You retain full control—perfect for adapting to sudden market shifts or refining strategies mid-trade.
Frequently Asked Questions (FAQs)
Q: Can I use free TradingView accounts for Signal Bots?
A: No. Webhook alerts require a paid TradingView subscription (Pro, Pro+, or Premium).
Q: What does “maxLag” mean in the alert message?
A: It defines the maximum allowable delay (in seconds) between signal generation and receipt. Default is 60 seconds.
Q: How do I test my signal before going live?
A: Use demo endpoints first (e.g., pap/algo/signal/trigger) to simulate without real funds.
Q: Can one signal trigger multiple bots?
A: Yes—publish one signal and link it to multiple bots across different pairs or settings.
Q: What happens if my internet drops?
A: As long as TradingView sends the alert and OKX receives it within maxLag, execution proceeds.
Q: Are spot markets supported?
A: Currently, Signal Bots support perpetual swaps only.
Sample Use Cases
Case A: MACD Golden Cross Strategy
Use Pine Script™ alertcondition() to detect crossovers:
alertcondition(goldenCross, title="MACD Golden Cross", message="{\"action\":\"ENTER_LONG\"}")Link this to OKX via Webhook for automatic long entries.
Case B: Python Automation
Send signals from a custom trading algorithm using HTTP POST requests—ideal for machine learning models or arbitrage systems.
Final Thoughts
Setting up an OKX Signal Bot with TradingView unlocks powerful automation capabilities for traders at all levels. From simple indicator-based alerts to complex algorithmic strategies, the integration offers flexibility, speed, and control.
With proper configuration and risk management, you can transform your trading approach—reacting faster than ever to market opportunities.
👉 Turn your trading ideas into automated actions—get started on OKX now.