Skip to main content

Alert Request Format v1.2.x

This guide details the required JSON format for TradingView alerts to work with Xerolite v1.2.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

FieldDescriptionMandatoryTradingView PlaceHolder
nameThe alert name is a critical identifier that groups related orders together. It is used for PnL calculation and order management. 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.Yes
symbolThe stock ticker symbol (e.g., 'AAPL').Yes
currencyThe currency of the trade (e.g., 'USD').Yes{{syminfo.currency}}
asset_classThe class of the asset, e.g., 'STOCK', 'FOREX', 'FUTURE', or 'INDEX'.Yes
exchThe exchange where the order will be placed (e.g., 'SMART' for US STOCK).Yes
acc_noIB 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
actionThe order action, either 'BUY' or 'SELL'.Yes{{strategy.order.action}}
qtyThe quantity of the asset to trade (e.g., '10.00').Yes{{strategy.order.contracts}}
tifTime-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_typeThe type of order, such as 'LIMIT', 'MARKET', 'TRAIL' (Trailing Stop). Default to 'MARKET' if not specifiedNo
priceThe 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 and TRAIL orders. For MARKET orders, the price is not rounded (only used for offset calculations).
Yes (with conditions){{strategy.order.price}}
slThe stop-loss price for the order (e.g., '110.00').
The calculated price will be rounded to the nearest valid increment based on IB market rules.
No
sl_offsetThe 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
tpThe 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_offsetThe 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
trail_amtThe trailing stop amount for the order. Can be a fixed amount (e.g., '10.00') or a percentage with % suffix (e.g., '5.00%').

Mandatory if 'order_type' = 'TRAIL': Required when using trailing stop orders.

Note: The trail_amt value itself is NOT rounded. However, the calculated trailing stop price will be rounded to the nearest valid increment based on IB market rules.
Yes (if order_type = 'TRAIL')

Price Rounding 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.

Trailing Stop Orders (v1.2.x)

XeroLite v1.2.0 introduces support for trailing stop orders. When using order_type: 'TRAIL', you must specify the trail_amt field:

  • Fixed Amount: Use a numeric value (e.g., '10.00') to set a fixed trailing amount
  • Percentage: Use a percentage value with % suffix (e.g., '5.00%') to set a percentage-based trailing stop

Example Trailing Stop Order

{
"name": "AAPL_TRAIL_001",
"symbol": "AAPL",
"currency": "USD",
"asset_class": "STOCK",
"exch": "SMART",
"action": "BUY",
"qty": "10",
"order_type": "TRAIL",
"price": "150.00",
"trail_amt": "5.00%"
}

Need Help?

If you encounter any issues or need assistance, please contact our support team at [email protected]