Trading Signal Bot Alert Message 2.0 Specifications

·

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:

👉 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:

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

ParameterRequiredDescription
idYes{{strategy.order.id}} – Unique identifier for the executed order
actionYes{{strategy.order.action}} – "buy" or "sell"
marketPositionYes{{strategy.market_position}} – Current position: "long", "flat", "short"
prevMarketPositionYes{{strategy.prev_market_position}} – Position before order execution
instrumentYes{{ticker}} or OKX instId (e.g., BTC-USDT-SWAP)
signalTokenYesProvided by OKX upon signal creation (authentication)
timestampYes{{timenow}} – UTC time in ISO 8601 format
maxLagNoMax delay in seconds (1–3600); default: 60
investmentTypeNo*Determines how position size is calculated
amountYesValue 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:

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:

For exit signals:

👉 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

ParameterRequiredDescription
actionYesENTER_LONG, ENTER_SHORT, EXIT_LONG, EXIT_SHORT
instrumentYesSame as Section A
signalTokenYesAs provided by OKX
timestampYes{{timenow}} in UTC
maxLagNoDefault: 60 seconds
orderTypeConditional"market" or "limit" (required only if limit)
orderPriceOffsetConditional% offset from market price (for limit orders)
investmentTypeOptional*Same options as Section A
amountOptional*Corresponding value

* If omitted, defaults apply:

Action Types Explained

The bot operates in one-way mode (no hedging):

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:

This allows strategic entry placement without constant monitoring.

Investment Management

Same sizing options as Section A, with emphasis on flexibility:


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:

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.