Skip to main content

Trailing Stop Parameters

Configure trailing stop loss orders that automatically adjust as price moves in your favor.

is_trailing_stop_enabled​

  • Type: boolean
  • Required: No
  • Default: false

Places a trailing stop instead of the take-profit order. The trailing stop is activated at take_profit_price and then follows the price at callback_rate percent. It needs both take_profit_price and callback_rate; without a take_profit_price, no trailing stop is placed. Your stop_loss_price stays in place as the normal stop-loss.

Paper bots do not place trailing stops.


callback_rate​

  • Type: float
  • Required: No (required if trailing stop enabled)
  • Description: Callback rate percentage for trailing stop

How It Works​

Once the price reaches the activation price (take_profit_price), the trailing stop follows the best price. It triggers when the price retraces by callback_rate percent from that peak. Exchanges limit the allowed range; values outside 0 to 5 are flagged by OptAlgo's input checks.

Example​

{
"strategy_key": "your_key",
"position_side": "LONG",
"action": "BUY",
"entry_price": 50000,
"stop_loss_price": 48000,
"take_profit_price": 53000,
"is_trailing_stop_enabled": true,
"callback_rate": 1.0
}

Scenario:

  1. Enter LONG at 50,000
  2. Stop-loss at 48,000; trailing stop activates at 53,000
  3. Price rises to 55,000 → trailing stop at ~54,450 (1% callback)
  4. Price rises to 60,000 → stop moves to ~59,400 (1% callback)
  5. If price drops 1% from peak, stop triggers

Complete Examples​

Long with Trailing Stop​

{
"strategy_key": "your_key",
"exchange": "BINANCE",
"ticker": "BTCUSDT.P",
"position_side": "LONG",
"action": "BUY",
"entry_price": 50000,
"stop_loss_price": 48000,
"take_profit_price": 53000,
"is_trailing_stop_enabled": true,
"callback_rate": 1.0,
"leverage": 10
}

Short with Trailing Stop​

{
"strategy_key": "your_key",
"exchange": "BINANCE",
"ticker": "BTCUSDT.P",
"position_side": "SHORT",
"action": "SELL",
"entry_price": 50000,
"stop_loss_price": 52000,
"take_profit_price": 47000,
"is_trailing_stop_enabled": true,
"callback_rate": 1.0,
"leverage": 5
}

Best Practices​

1. Use for Trend Following​

{
"take_profit_price": 53000, // activation price of the trailing stop
"is_trailing_stop_enabled": true,
"callback_rate": 1.0
}

2. Tighter Callbacks for Scalping​

{
"callback_rate": 0.5 // 0.5% callback
}

3. Wider Callbacks for Swing Trading​

{
"callback_rate": 2.0 // 2% callback
}