Alert Request Format v1.1.x
Version Note: This format is for XeroLite version 1.1.0 and above (first stable release with limit orders, stop-loss, and take-profit). Version 1.1.0 introduced automatic price rounding. Stop-loss and take-profit features were first introduced in version 1.0.0 Beta, but version 1.1.0 is the recommended stable release for production use.
This guide details the required JSON format for TradingView alerts to work with XeroLite v1.1.x. Each field in the alert message must follow the specified format below.
Built-in Tools to Help You
- Alert Request Builder: Use Xerolite's built-in tool to easily construct your alert requests in the correct JSON format.
- Alert Message Validator & Sender: Test and validate alert messages and send test orders directly to XeroLite. See Alert Message Validator & Sender for details.
Important Note About Alert Names
When multiple orders share the same alert name, they are considered part of the same trading strategy. This ensures accurate profit/loss tracking and allows the system to manage pending orders effectively. Always use consistent alert names for related orders.
Field Reference Table
| Field | Description | Mandatory | TradingView PlaceHolder |
|---|---|---|---|
| name | The alert name is a critical identifier that groups related orders together. It is used for PnL calculation and order management. | Yes | |
| symbol | The stock ticker symbol (e.g., 'AAPL'). | Yes | |
| currency | The currency of the trade (e.g., 'USD'). | Yes | {{syminfo.currency}} |
| asset_class | The class of the asset, e.g., 'STOCK', 'FOREX', 'FUTURE', or 'INDEX'. | Yes | |
| exch | The exchange where the order will be placed (e.g., 'SMART' for US STOCK). | Yes | |
| acc_no | IB account number. Required only if multiple accounts are linked to the same TWS login. If a single account is used, this field is optional and will be ignored if provided. | No | |
| action | The order action, either 'BUY' or 'SELL'. | Yes | {{strategy.order.action}} |
| qty | The quantity of the asset to trade (e.g., '10.00'). | Yes | {{strategy.order.contracts}} |
| tif | Time-in-Force for the order, such as 'DAY' or 'GTC' (Good Til Cancel) or 'IOC' (Immediate or Cancel). Default to 'DAY' if not specified. | No | |
| order_type | The type of order, such as 'LIMIT', 'MARKET'. Default to 'MARKET' if not specified | No | |
| price | The price for the order if 'order_type' is 'LIMIT' (e.g., '210.00'). Mandatory if 'order_type' = 'LIMIT': Acts as the limit price for the order. If sl_offset or tp_offset is configured, stop-loss and take-profit offsets will be calculated based on this price. Mandatory for 'MARKET' orders if sl_offset or tp_offset is configured as it will be used for stop-loss and take-profit calculations. The price will be rounded to the nearest valid increment based on IB market rules for LIMIT orders. For MARKET orders, the price is not rounded (only used for offset calculations). | Yes (with conditions) | {{strategy.order.price}} |
| sl | The stop-loss price for the order (e.g., '110.00'). Note: This field is NOT rounded when provided directly. To ensure automatic price rounding, use sl_offset instead. | No | |
| sl_offset | The stop-loss offset as a percentage or fixed value. Will be ignored if 'sl' is configured. Examples: '10%': Calculates stop-loss dynamically based on the percentage of the price. BUY: SL = Price – (Price × 10%) SELL: SL = Price + (Price × 10%) '25.00': Fixed value offset. BUY: SL = Price – 25.00 SELL: SL = Price + 25.00 The calculated price will be rounded to the nearest valid increment based on IB market rules. | No | |
| tp | The take-profit price for the order (e.g., '130.00'). Note: This field is NOT rounded when provided directly. To ensure automatic price rounding, use tp_offset instead. | No | |
| tp_offset | The take-profit offset as a percentage or fixed value. Will be ignored if 'tp' is configured. Examples: '10%': Calculates take-profit dynamically based on the percentage of the price. BUY: TP = Price + (Price × 10%) SELL: TP = Price – (Price × 10%) '29.00': Fixed value offset. BUY: TP = Price + 29.00 SELL: TP = Price – 29.00 The calculated price will be rounded to the nearest valid increment based on IB market rules. | No |
Price Rounding Rules
Version Note: Automatic price rounding was introduced in version 1.1.0. In version 1.0.0 Beta, you may need to manually ensure prices comply with IB market rules.
For limit orders, stop-loss, and take-profit prices, XeroLite will automatically round prices to the nearest valid increment based on Interactive Brokers market rules. This ensures your orders comply with exchange requirements.
For detailed information about how price rounding works, see Price Rounding Rules.
Need Help?
If you encounter any issues or need assistance, please contact our support team at [email protected]