How to Set Up a Signal Trading Bot on OKX with TradingView

·

With the launch of signal bots, users and signal providers can now publish and configure signal bots using their custom TradingView signals. To start trading on OKX with signals, follow this detailed guide.

Step 1: Access the Signal Bot

  1. Log in to your OKX account.
  2. Navigate to Trade > Trading Bots > Marketplace.
  3. Select the Signal Bot subtab and click Create.

Step 2: Create a Signal

  1. Click Add Custom Signal.
  2. Name your signal and add an optional description (up to 500 characters).
  3. Click Create Signal to proceed.

Key Specifications:

👉 Explore Advanced Signal Configurations

Step 3: Configure TradingView Alerts

For Strategy Script Users (strategy.*()):

  1. Configure your Pine Script strategy in the Pine Editor.
  2. Set order parameters (USDT, contracts, or % equity).
  3. Generate alerts using strategy.order templates.

Example Alert Message:

{
"id": "{{strategy.order.id}}",
"action": "{{strategy.order.action}}",
"instrument": "{{ticker}}",
"signalToken": "YOUR_TOKEN",
"investmentType": "base",
"amount": "{{strategy.order.contracts}}"
}

For Indicator Script Users:

  1. Define conditions (e.g., MACD Golden Cross).
  2. Use OKX’s ENTER_LONG/EXIT_SHORT templates for alerts.

For Chart Analysis Users:

  1. Set alerts based on technical conditions (e.g., RSI-14 crosses 30).
  2. Insert OKX’s AlertMsg specifications in the alert message.

Step 4: Signal Bot Setup

  1. Click Create Bot.
  2. Configure:

    • Tradable pairs
    • Leverage ratio
    • Margin allocation
  3. Advanced settings:

    • Order type (Market/Limit)
    • Take-profit/Stop-loss levels

Step 5: Monitor and Manage Your Bot


FAQ

Q: How do I ensure TradingView alerts match OKX orders?
A: Use the investmentType: "base" and amount: "{{strategy.order.contracts}}" settings in your alert template.

Q: Can I use third-party programs to send signals?
A: Yes, but whitelist your IP with OKX support for live trading.

Q: What if my bot stops unexpectedly?
A: Check the Signal Logs in Bot Details for error resolution.

👉 Learn More About Signal Trading


Appendix

A. Sample MACD Script with Alerts

//@version=5
indicator("MACD Alert Example")
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
alertcondition(ta.crossover(macdLine, signalLine), "Golden Cross", "")

B. Python Webhook Request Example

import requests
signal_data = {
    "action": "ENTER_LONG",
    "instrument": "BTC-USDT-SWAP",
    "signalToken": "YOUR_TOKEN",
    "investmentType": "percentage_balance",
    "amount": "100"
}
requests.post("https://www.okx.com/join/BLOCKSTARalgo/signal/trigger", json=signal_data)

C. Recommended Scripts