How to Set Up an OKX Signal Trading Bot Using TradingView

·

With the launch of signal bots, TradingView users and signal providers can now publish and configure signal bots for their TradingView signals. Follow this step-by-step guide to start trading with signals on OKX.

For a comprehensive guide on alert message specifications, refer to the Alert Message Specifications section.

If you encounter issues, consult the FAQ guide—a valuable resource for troubleshooting product-related challenges.

Step 1: Access the Signal Bot

  1. Log in to your OKX account.
  2. Navigate to TradeTrading BotsMarketplace.
  3. Select the Signal Bot subtab and click Create.

Step 2: Create Your Signal

After clicking Create, you’ll see a page prompting you to:

  1. Add the Webhook URL (auto-generated by OKX).
  2. Configure AlertMsg Specifications for TradingView notifications.

Two Alert Configuration Methods:

  1. TradingView (Strategy Scripts): For users leveraging strategy.*() functions.
  2. Custom (Indicators/Third-Party Tools): For broader use cases, including chart alerts and third-party programs.

Pine Script™ Overview: Strategy vs. Indicator

| Feature | Strategy Scripts | Indicator Scripts |
|-----------------------|------------------------------------------|---------------------------------------|
| Purpose | Backtesting/live trading | Technical analysis |
| Broker Emulator | Yes | No |
| Resource Intensity| Higher | Lower |

👉 Learn more about Pine Script™ best practices

Step 3: Configure TradingView Alerts

3.1 TradingView Strategy Scripts

  1. Save & Add Script: Configure your strategy in Pine Editor and attach it to the chart.
  2. Set Order Parameters: Align order size (USDT/contracts/% of equity) with OKX requirements.

    • Example for USDT-based orders:

      {
        "investmentType": "base",
        "amount": "{{strategy.order.contracts}}"
      }
  3. Create Alert:

    • Condition: Order fills only.
    • Message: Paste OKX’s AlertMsg template.
    • Webhook URL: Enter the URL from OKX.

3.2 TradingView Indicators/Studies

  1. Attach your indicator to the chart.
  2. Set AlertCondition (e.g., MACD Golden Cross).
  3. Use OKX’s ENTER_LONG/EXIT_SHORT message templates.

3.3 Chart Analysis Alerts

  1. Set conditions (e.g., RSI-14 crossing 30).
  2. Add OKX AlertMsg specifications.

3.4 Third-Party Programs

Step 4: Set Up Your Signal Bot

  1. Basic Settings:

    • Trading pairs, leverage, margin allocation.
  2. Advanced Options:

    • Order type (market/limit).
    • Take-profit/stop-loss levels.
  3. Confirm to launch the bot.

Step 5: Manage Your Bot


Appendix

A. Example: MACD Alert Script

//@version=5
indicator("MACD Sample Script", overlay=true)
goldenCross = ta.crossover(macdLine, signalLine)
alertcondition(goldenCross, "MACD Golden Cross", "")

B. Python Webhook Request

signal_data = {
  "action": "ENTER_LONG",
  "instrument": "BTC-USDT-SWAP",
  "signalToken": "YOUR_TOKEN",
  "timestamp": datetime.utcnow().isoformat(),
  "investmentType": "percentage_balance",
  "amount": "100"
}
response = requests.post(LIVE_TRADING_URL, json=signal_data)

C. Sample Scripts


FAQ

Q1: How do I troubleshoot signal delays?
A1: Check your webhook URL and TradingView subscription status.

Q2: Can I use custom indicators?
A2: Yes—configure alerts using the Custom method.

Q3: What leverage is recommended for beginners?
A3: Start with 5–10x to manage risk.

👉 Explore advanced signal strategies