How to Set Up an OKX Trading Bot with TradingView Signals

·

With the launch of the Signals Bot, TradingView users and signal providers can now publish and configure a signals bot using their TradingView alerts. Follow this step-by-step guide to start trading with signals on OKX.

Step 1: Access the Signals Bot

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

Step 2: Create Your Signal

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

Key Configurations:


Step 3: Configure TradingView Alerts

Method A: Strategy Scripts (Pine Script™)

  1. Add Script: Save and add your Pine Script™ strategy to the chart.
  2. Set Alerts: Configure alerts via the "Alerts" button, selecting "Only Completed Orders."
  3. Webhook URL: Paste the OKX-generated webhook URL under "Notifications."

Method B: Custom Alerts

  1. Condition: Set alert conditions based on indicators or chart patterns.
  2. Alert Message: Use OKX’s preformatted AlertMsg template.
  3. Webhook Integration: Link the OKX webhook URL.

Step 4: Set Up Your Signals Bot

  1. Basic Settings:

    • Select trading pairs.
    • Set leverage ratio and margin amount.
  2. Advanced Options:

    • Choose order type (market/limit).
    • Configure take-profit (TP) and stop-loss (SL) levels.
  3. Confirm: Finalize bot creation.

Step 5: Monitor and Manage Your Bot


FAQ Section

Q1: Can I use custom Pine Script™ indicators?

A1: Yes! Both strategy scripts (strategy.*()) and custom indicators (alertcondition()) are supported.

Q2: What’s the minimum margin required?

A2: No fixed minimum. Allocate funds based on your risk tolerance.

Q3: How do I troubleshoot failed signals?

A3: Check:


Appendix

Example 1: MACD Alert Script

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

Example 2: Python Webhook Request

import requests
signal_data = {
    "action": "ENTER_LONG",
    "instrument": "BTC-USDT-SWAP",
    "signalToken": "YOUR_TOKEN",
    "timestamp": "2023-10-01T12:00:00.000Z"
}
response = requests.post("https://www.okx.com/join/BLOCKSTARalgo/signal/trigger", json=signal_data)

👉 Explore Advanced Trading Strategies
👉 Download Free TradingView Scripts

For further details on AlertMsg specifications, refer to OKX’s official documentation.