Automating your trading strategy has never been easier with the advanced integration between TradingView and OKX through Signal Bots. Whether you're a seasoned PineScript™ developer or prefer manual alert setups, OKX supports flexible and robust alert message specifications to ensure your signals are executed accurately and efficiently. This guide dives into the essential components of the Trading Signal Bot Alert Message 2.0, covering both PineScript™-specific and universally compatible formats.
Understanding Signal Bot Compatibility
OKX’s Signal Bot system is designed for maximum flexibility, supporting two distinct alert formats tailored to different user needs:
- PineScript™ Strategy Users: Ideal for those building automated strategies using
strategy.*()functions in PineScript™. - Universal Format Users: A flexible option for anyone using custom indicators, manual alerts, or non-strategy scripts.
👉 Discover how to connect your strategy to real-time trading with powerful automation tools.
Both formats are fully supported and intelligently parsed by the system based on the structure of the incoming message—ensuring seamless execution regardless of your signal generation method.
Pine Script™: Strategy vs Indicator
Before diving into specifications, it's important to understand the difference:
- Strategies use
strategy.entry(),strategy.exit(), orstrategy.order()to simulate trades and generate backtest results. They interact with a broker emulator and are perfect for automated trading logic. - Indicators perform calculations and visualizations but do not support order simulation. They’re faster and lighter but lack native trade execution features.
You can use either format below—OKX automatically detects and processes your alert correctly.
Section A: For PineScript™ Strategy Users
This format is optimized for traders who build algorithms using PineScript™ strategy scripts. It leverages built-in placeholders like {{strategy.order.id}} and {{strategy.market_position}} to synchronize your strategy logic directly with OKX.
Required & Optional Parameters
| Parameter | Required | Description |
|---|---|---|
id | Yes | {{strategy.order.id}} – Unique identifier for the executed order |
action | Yes | {{strategy.order.action}} – "buy" or "sell" |
marketPosition | Yes | {{strategy.market_position}} – Current position: "long", "flat", "short" |
prevMarketPosition | Yes | {{strategy.prev_market_position}} – Position before order execution |
instrument | Yes | {{ticker}} or OKX instId (e.g., BTC-USDT-SWAP) |
signalToken | Yes | Provided by OKX upon signal creation (authentication) |
timestamp | Yes | {{timenow}} – UTC time in ISO 8601 format |
maxLag | No | Max delay in seconds (1–3600); default: 60 |
investmentType | No* | Determines how position size is calculated |
amount | Yes | Value based on selected investment type |
* Defaulted to percentage_investment (entry) or percentage_position (exit). For full compatibility, set investmentType: base and amount: {{strategy.order.contracts}}.
Key Field Explanations
instrument – Matching Market Pairs
Use either:
- TradingView ticker: e.g.,
"BTCUSDT.P" - OKX instrument ID: e.g.,
"BTC-USDT-SWAP"(recommended for precision)
signalToken – Secure Signal Authentication
Each signal created on OKX generates a unique token. Copy this into your TradingView alert to authenticate and route signals securely.
maxLag – Preventing Outdated Executions
Ensures signals older than the defined threshold (in seconds) are ignored—critical for high-frequency strategies.
investmentType & amount – Position Sizing Logic
For entry signals:
base: Fixed amount in base currency (e.g., 0.5 BTC)margin: Quote currency value (e.g., 1000 USDT)contract: Number of contractspercentage_balance: % of available marginpercentage_investment: % of fixed active investment
For exit signals:
percentage_position: Close X% of current position
👉 Maximize your strategy’s potential with precise order routing and execution control.
Section B: Universally Compatible Format
This format works across all signal types—including indicators, manual alerts, and third-party tools—making it ideal for broad compatibility.
Core Parameters
| Parameter | Required | Description |
|---|---|---|
action | Yes | ENTER_LONG, ENTER_SHORT, EXIT_LONG, EXIT_SHORT |
instrument | Yes | Same as Section A |
signalToken | Yes | As provided by OKX |
timestamp | Yes | {{timenow}} in UTC |
maxLag | No | Default: 60 seconds |
orderType | Conditional | "market" or "limit" (required only if limit) |
orderPriceOffset | Conditional | % offset from market price (for limit orders) |
investmentType | Optional* | Same options as Section A |
amount | Optional* | Corresponding value |
* If omitted, defaults apply:
- Single-pair bots: Enter with 100% of available balance
- Multi-pair bots: Enter with 50% of available balance
- Exit signals: Close 100% of open position by default
Action Types Explained
The bot operates in one-way mode (no hedging):
- ENTER_LONG / ENTER_SHORT: Open directional positions
- EXIT_LONG / EXIT_SHORT: Partially or fully close existing positions
Order Execution Settings
Market Orders
Execute instantly at prevailing market price. No additional parameters needed.
Limit Orders
Require orderPriceOffset to define price relative to bid/ask:
- ENTER_LONG:
[1 - offset%] × Bid - ENTER_SHORT:
[1 + offset%] × Ask - EXIT_LONG:
[1 + offset%] × Ask - EXIT_SHORT:
[1 - offset%] × Bid
This allows strategic entry placement without constant monitoring.
Investment Management
Same sizing options as Section A, with emphasis on flexibility:
- Let subscribers define their own risk via bot settings
- Signal providers can send pure trigger signals (
action,instrument,timestamp) and let users control position size
Frequently Asked Questions (FAQs)
Q: Can I switch between PineScript™ and universal formats?
A: Yes. The system auto-detects the format based on parameter structure—no configuration changes needed.
Q: What happens if my signal is delayed beyond maxLag?
A: Signals exceeding the maxLag threshold are rejected to prevent execution under outdated market conditions.
Q: How do I find my signalToken?
A: After creating a signal on OKX, go to its details page—the token appears in the recommended alert message section.
Q: Is multi-entry supported?
A: Yes. Multiple ENTER signals accumulate positions until an EXIT is triggered.
Q: Do limit orders guarantee execution?
A: No. Limit orders execute only if market price reaches your defined level within the valid window.
Q: Can I use percentage-based sizing with manual alerts?
A: Absolutely. Set investmentType: percentage_balance and specify the desired % in amount.
Final Recommendations
To ensure smooth integration:
- Always include
{{timenow}}and a validsignalToken - Use OKX instrument IDs (
BTC-USDT-SWAP) for accuracy - Test alerts in demo mode before live deployment
- Monitor execution logs in your OKX Bot Dashboard
Whether you're coding a complex PineScript™ strategy or sending manual signals, OKX’s Signal Bot provides the reliability and precision needed for modern algorithmic trading.
👉 Start automating your trading signals with a secure, high-performance platform today.