Protect Profits Automatically with Trailing Stop Orders with Xerolite v1.2.0

Protect Profits Automatically with Trailing Stop Orders with Xerolite v1.2.0

Xerolite v1.2.0 introduces Trailing Stop Orders, enabling traders to automatically protect profits while allowing trades to continue benefiting from favorable market moves.

A trailing stop dynamically follows the market price at a predefined distance. As the price moves in your favor, the stop adjusts automatically. When the market reverses by that distance, the position is exited to preserve gains.


How to Place a Trailing Stop Order

To place a trailing stop order in Xerolite, set order_type to TRAIL and specify trail_amt. Xerolite automatically creates a parent–child order structure for you:

  • Parent order: LIMIT order to enter the trade
  • Child order: TRAIL order to manage the exit

The trailing stop becomes active only after the parent order is filled.

Example 1: Trailing Stop Using Percentage

In this example, trail_amt is a percentage. The trailing stop will follow the market price with a fixed percentage distance.

{
  "name": "AAPL_Trail_Percent",
  "symbol": "AAPL",
  "action": "BUY",
  "qty": "10",
  "order_type": "TRAIL",
  "price": "150.00",
  "trail_amt": "2.00%"
}

How it works:

  • LIMIT BUY order is placed at $150.00
  • After fill, the trailing stop follows the highest price at a 2% distance
  • If price drops 2% from its peak, the position exits automatically

Example 2: Trailing Stop Using Fixed Amount

In this example, trail_amt is a fixed amount. The trailing stop will follow the market price by a constant price difference.

{
  "name": "AAPL_Trail_Amount",
  "symbol": "AAPL",
  "action": "BUY",
  "qty": "10",
  "order_type": "TRAIL",
  "price": "150.00",
  "trail_amt": "3.00"
}

How it works:

  • LIMIT BUY order is placed at $150.00
  • The trailing stop stays exactly $3.00 below the highest market price
  • If price falls by $3.00 from the peak, the position exits automatically

Other Improvements in v1.2.0

  • Upgraded to TWS API v10.37.02 for improved compatibility and stability
  • Pagination added to Alerts and Transactions to improve performance and usability
  • Enhanced Transactions view with a clear parent–child hierarchy, making combo orders easier to understand

Try Xerolite v1.2.0

Download Xerolite:
https://www.xeroflex.com/xerolite-download-and-resources/

Demo:
https://stgxerolite.xeroflex.com