Guide

Exiting positions

Once a bot has opened a position, Trademade will monitor it waiting for one of the following conditions:

  • Contract expiration
  • Profit target
  • Stop loss
  • Manual close through Telegram

If you don't specify any explicit exit conditions, the bot will hold the position until expiration.

Do not close positions managed by Trademade outside of Trademade! Closing trades through TWS will desynchronize the Trademade database and may cause undesired order executions.

Profit target

Setting the profitTargetPercent parameter on a bot will close the position at the specified profit target percentage. Trademade will generate a standing closing order that will be submitted shortly after the position opens.

Disabling closing orders

Profit target closing orders can be toggled with the /btc command.

Stop losses

Trademade is monitoring all open trades in real-time and receives market data updates multiple times a second, and stop losses will usually trigger the submission of a closing order within one second of a stop condition being breached. This behavior can be customized through the gracePeriodMs parameter.

Trademade does not use standing orders for stop losses.

Trademade has multiple stop loss triggers:

There is an exception to the normal stop condition case, and that is when Trademade detects market illiquidity in a position. Market illiquidity is detected as a large bid/ask spread (> 25% difference) on the position (e.g. a bid price of 2.0 and an ask price of 7.0). When this occurs, Trademade will defer the stop for up to 10 seconds (or for gracePeriodMs, whichever is greater) in an attempt to wait for market liquidity to return.

For strangles and iron condors, the entire position will be closed when either side is triggered.

A stop loss order will attempt to exit the position as soon as possible, while trying to minimize slippage. For credit positions, by default Trademade will attempt to use a relative order when closing a single leg. If the closing order has multiple legs, the closing order will be priced at the current mid price (plus one increment toward the ask). The order will then be adjusted up by one increment from the current mid price every 3 seconds. In both cases, if the order hasn't filled after 25 seconds, it will be canceled and replaced with a market order.

When stopping out multi-leg credit positions, Trademade will initially only close the short leg of the position to attempt to achieve the best fill with minimal slippage. The long leg will be closed in a separate order, based on the closeLong bot parameter..

Disabling stops

Stops can be dynamically toggled with the /stops command.

Manually closing a position

The /close command can be used to manually close a position. The closing order logic is identical to logic used when stopping out a position.

Consider disabling a bot before manually closing a position! Otherwise it's possible the bot could enter a new position shortly after the position closes.

Closing multileg positions

For multileg positions (spreads, short strangles, iron condors), Trademade allows you to customize how the legs should be closed when the position is closed via the closeLong bot parameter.

The default value is auto, which means that Trademade will attempt to close long positions when shorts are closed. If there are bids on the long legs when the position is being closed, Trademade will include the long legs when it submits its closing order. If there are no bids on a long leg, Trademade will submit a market order to sell the remaining longs once the order has been closed.

Scripting

Scripts can be used to define custom logic for when to exit a position.

Previous
Entering positions