Skip to content
Sign In

Learning / Syntax / sl-or-tp

sl-or-tp - Combined Stop Loss + Take Profit

Place Take Profit and Stop Loss together with automatic One-Cancels-Other monitoring.

What is sl-or-tp?

sl-or-tp is the easiest way to protect your positions with both upside (take profit) and downside (stop loss) protection in a single command.

  • Atomic Placement

    Places both TP and SL orders simultaneously - no delay between them

  • Automatic OCO Monitoring

    When one order fills (TP or SL), the other is automatically cancelled. No manual cleanup needed.

  • Set and Forget

    Perfect for swing trades - set your exit levels and let the system manage them

Syntax

Smart Syntax
sl-or-tp [long|short] <amount> sl off <sl_value> tp off <tp_value>
sl-or-tp [long|short] <amount> sl off <sl_value> tp off <tp_value> #tag
sl-or-tp [long|short] <amount> sl off <sl_value> tp off <tp_value> mark|last|index

Parameters

long|shortOptional

Type: keyword | Values: long, short (or buy, sell as aliases)

Optional when a preceding market command identifies the position, or when the exchange reports a single open position—even in a separate webhook.

With both sides open in hedge mode and no preceding market command, select the closing side: short protects the long; long protects the short. Explicit side selection is supported on Bybit, OKX and WEEX Futures.


amountRequired

Type: number or string

How much of your position to close with TP/SL. Most commonly use 100%p to close entire position:

FormatExampleMeaning
%p100%p100% of position (full exit)
%p50%p50% of position (partial exit)
number0.010.01 BTC (absolute amount)

tp off valueRequired

Type: number or string

Take Profit offset. Places a limit order at this distance INTO profit:

  • tp off 100 - Take profit after $100 move into profit
  • tp off 5% - Take profit after 5% price move into profit
  • tp off e5% - 5% from average entry (recommended for open positions)
  • tp @ 52000 - Absolute price of $52,000
  • tp rr3 - Risk/Reward ratio: TP at 3x the SL distance (3:1 R/R)
  • tp rr2.5 - Risk/Reward ratio: TP at 2.5x the SL distance (2.5:1 R/R)

sl off valueRequired

Type: number or string

Stop Loss offset. Places a stop market order at this distance INTO loss:

  • sl off 50 - Stop loss after $50 move into loss
  • sl off 2% - Stop loss after 2% price move into loss
  • sl off e2% - 2% from average entry (recommended for open positions)
  • sl @ 48000 - Absolute price of $48,000

#tagOptional

Type: tag identifier

Label both orders for later reference. Use #tag syntax. Useful for managing multiple positions.


reduceOptional

Type: flag keyword

Add reduce keyword to ensure orders can only reduce position size, not increase it. Usually not needed as this command is designed for closing positions.


mark | last | indexOptional

Type: keyword | Default: last

Which price to use for triggering both SL and TP orders:

TriggerDescriptionBest For
markMark priceMost reliable, manipulation-resistant
lastLast traded price (default)Fastest response
indexIndex priceBased on spot exchanges, very stable

Real-World Examples

1. Basic Long Trade with 2:1 Risk/Reward

Enter a long position, take profit at +4%, stop loss at -2%. This gives you 2:1 reward to risk ratio.

Smart Syntax
BTCUSDT on My_API_Key
// Enter long position
market long 0.01
// Protect with 4% TP and 2% SL
sl-or-tp short 100%p sl off 2% tp off 4%

Risk:Reward = 1:2 - Risk $100 to make $200. When either TP or SL hits, the other is auto-cancelled.

2. Entry-Relative Offsets (Best Practice)

Use entry-relative offsets (e%) for more precise TP/SL based on YOUR entry price.

Smart Syntax
ETHUSDT on My_API_Key
market long 0.5
// TP/SL relative to entry price
sl-or-tp short 100%p sl off e2.5% tp off e5%

Using e5% means "5% from MY entry price", not from current market price. This is more accurate when market is moving quickly.

3. Partial Exit Strategy

Take profit on 50% of position, let the rest run with a separate stop.

Smart Syntax
BTCUSDT on My_API_Key
market long 0.02
// Exit 50% at 3% profit
sl-or-tp short 50%p sl off 1.5% tp off 3%
// Let remaining 50% run with wider stop
sl off e2%

This secures partial profits while keeping exposure for bigger moves. First 50% exits at 3% profit, remaining position has a 2% stop loss.

4. Absolute Price Targets

Take profit at a specific resistance level, stop loss at support.

Smart Syntax
BTCUSDT on My_API_Key
// Buy at market (assuming ~$50,000)
market long 0.01
// TP at resistance, SL at support
sl-or-tp short 100%p sl @ 49000 tp @ 52000

Using absolute prices (@ 52000) is perfect when trading at key levels. TP at $52k resistance, SL at $49k support.

5. Automatic Risk/Reward Ratio

Use the rr notation to automatically calculate TP based on SL distance.

Smart Syntax
BTCUSDT on My_API_Key
// Set SL at 2%, TP automatically at 6% (3:1 R/R)
market long 0.01
sl-or-tp short 100%p sl off 2% tp rr3

tp rr3 automatically calculates TP at 3× the SL distance. If SL is 2% away, TP becomes 6% away (3:1 reward to risk). This works with any SL value: sl off e1.5% tp rr2.5 would set TP at 3.75% (2.5× of 1.5%).

6. Short Position with TP/SL

Enter a short and protect it with TP below and SL above.

Smart Syntax
BTCUSDT on My_API_Key
// Enter short position
market short 0.01
// TP below, SL above (for shorts)
sl-or-tp long 100%p sl off 1.5% tp off 3%

For shorts, use long to close (buy back). TP/SL offsets work the same way - positive values automatically go in the correct direction (TP below, SL above for shorts).

Best Practices

  • Always define both TP and SL - Never trade without protecting both sides

  • Use 2:1 or better R:R - Aim for at least 2x reward compared to risk (e.g., tp=4%, sl=2%)

  • Prefer entry-relative offsets - Use e% for more accurate TP/SL based on your actual entry

  • Use 100%p for full exits - Closes entire position regardless of size

  • Place immediately after entry - Don't wait, protect your position right away

Exchange-Specific Behavior

sl-or-tp creates two orders and monitors them with OCO logic. Implementation varies:

ExchangeNative OCOImplementation
BinanceYesNative OCO with GTE_GTC (requires workaround for SHORT)
ByBitYesNative position TP/SL
BitMEXYesNative OCO via clOrdLinkID
BitgetNoFlipr.Cloud OCO Monitor (polling)
BitunixNoFlipr.Cloud OCO Monitor (polling)
HTXNoFlipr.Cloud OCO Monitor (polling)
KuCoinNoFlipr.Cloud OCO Monitor (polling)

Related Commands

smart-oco

- Position-aware OCO for advanced exit strategies

stoploss / takeprofit

- Standalone SL or TP (no OCO monitoring)

oco

- Monitor existing orders with OCO logic

market

- Use inline sl/tp for simpler setups