How to Set Up a TradingView Signal Bot on OKX

·

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:

After completing these fields, click Create Signal to proceed.

You'll then be directed to a new page displaying two critical pieces of information:

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:

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

  1. Set Up Your Strategy Script

    • Open the Pine Editor.
    • Save and add your strategy script to the chart.
  2. 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:

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:

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.

  1. 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
  2. Configure Message & Webhook

    • Paste the OKX AlertMsg JSON template into the message field
    • Replace signalToken with 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

  1. Save and apply your Pine Script indicator to the chart.
  2. Click Alerts > + New Alert
  3. Select your indicator and set the appropriate alertcondition() (e.g., “MACD Golden Cross”)
  4. Insert the OKX AlertMsg JSON template into the message box
  5. Select Webhook URL, paste your OKX webhook, and create the alert

✅ Important: OKX supports four key actions:

  • ENTER_LONG
  • EXIT_LONG
  • ENTER_SHORT
  • EXIT_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:

  1. Click Alerts > + New Alert
  2. Define condition (e.g., “RSI(14) crosses above 30”)
  3. Paste the appropriate OKX AlertMsg format into the message field
  4. Add your webhook URL under notifications
  5. 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:

Then customize advanced options:

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:

Key Management Features

  1. Adjust Bot Margin: Add or remove funds anytime.
  2. Manual Orders: Place trades outside signal input.
  3. Close Positions Instantly: Exit any open trade with one click.
  4. Stop the Bot: Close all positions and cancel pending orders safely.

Stopping methods:


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.