Repository navigation
Advanced Order Types
API v3 introduces new order types that give you more control over your trades. Let's break them down.
A stop-loss that follows your profits. As the price moves in your favor, the stop moves with it, locking in gains while still protecting you from reversals.
For Long Positions:
- Set activation price (when trailing starts)
- Set callback rate (how far behind to trail)
- Price hits activation → trailing begins
- Price goes up → stop follows at callback distance
- Price drops to stop → order executes
Example:
- Entry: $50,000
- Activation: $52,000 (wait for 4% profit)
- Callback: 2% (trail 2% behind peak)
What happens:
- Price hits $52,000 → trailing starts, stop at $50,960 (2% below)
- Price goes to $55,000 → stop moves to $53,900
- Price goes to $60,000 → stop moves to $58,800
- Price drops to $58,800 → sells, you keep most of the $10k gain
$order = Bingx::trade()->order()
->futures()
->symbol('BTC-USDT')
->sell() // Sell to close long
->long()
->type('TRAILING_STOP_MARKET')
->activationPrice(52000.0)
->callbackRate(2.0) // 2%
->quantity(1.0)
->execute();$order = Bingx::trade()->order()
->futures()
->symbol('ETH-USDT')
->buy() // Buy to close short
->short()
->type('TRAILING_STOP_MARKET')
->activationPrice(2800.0) // Start trailing when price drops to $2800
->callbackRate(1.5) // Trail 1.5% above lowest
->quantity(10.0)
->execute();Tight (0.5-1%):
- Locks in profits quickly
- Gets stopped out more often
- Good for volatile markets
- Day trading
Medium (1-2%):
- Balanced approach
- Most common choice
- Swing trading
Loose (2-5%):
- Gives room to breathe
- Fewer false stops
- Position trading
- Strong trends
// You bought BTC at $48,000
// Current price: $51,000
// You want to protect profits but let it run
$order = Bingx::trade()->order()
->futures()
->symbol('BTC-USDT')
->sell()
->long()
->type('TRAILING_STOP_MARKET')
->activationPrice(51000.0) // Start now
->callbackRate(1.5) // Trail 1.5%
->quantity(1.0)
->execute();
// Price goes to $55,000 → stop at $54,175 (1.5% below)
// You're guaranteed at least $6,175 profit ($54,175 - $48,000)
// But if it keeps going up, you keep more!A two-step order: wait for a trigger price, then place a limit order (not market). This gives you better control than a regular stop-market.
Stop-Market Problem:
- Trigger hits → market order → you get whatever price
- In volatile markets, slippage can be huge
- You wanted out at $49k, got filled at $48.5k
Trigger-Limit Solution:
- Trigger hits → limit order placed
- You control the execution price
- Might not fill if price moves too fast, but no slippage
$order = Bingx::trade()->order()
->futures()
->symbol('BTC-USDT')
->buy()
->long()
->type('TRIGGER_LIMIT')
->stopPrice(49500.0) // Trigger price
->price(50000.0) // Limit price
->margin(100)
->leverage(10)
->execute();What happens:
- Price drops to $49,500 → order triggers
- Limit buy order placed at $50,000
- Order fills when price reaches $50,000 or better
// You're long BTC at $52,000
// Set a stop-loss with price control
$order = Bingx::trade()->order()
->futures()
->symbol('BTC-USDT')
->sell()
->long()
->type('TRIGGER_LIMIT')
->stopPrice(50000.0) // Trigger at $50k
->price(49800.0) // But only sell at $49.8k or better
->quantity(1.0)
->execute();Trade-off:
- Pro: No slippage, you control the price
- Con: Might not fill if market gaps through your limit
Use Trigger-Limit when:
- You want price control
- Market is liquid
- You can afford to miss the fill
- Protecting profits, not preventing disaster
Use Stop-Market when:
- You MUST get out
- Preventing liquidation
- Emergency exits
- Market is moving fast
Combined trailing take-profit and stop-loss in one order. Set both your profit target and stop-loss, with trailing on the TP side.
$order = Bingx::trade()->order()
->futures()
->symbol('BTC-USDT')
->buy()
->long()
->type('TRAILING_TP_SL')
->quantity(1.0)
->takeProfitPrice(55000.0) // Take profit at $55k
->stopLossPrice(48000.0) // Stop loss at $48k
->trailingStopPercent(1.0) // Trail TP by 1%
->execute();What happens:
If price goes up:
- Hits $55,000 → trailing starts
- Goes to $58,000 → TP trails to $57,420 (1% below)
- Drops to $57,420 → takes profit
If price goes down:
- Hits $48,000 → stops out at loss
// Entry: $50,000
// Target: 10% profit ($55,000)
// Risk: 4% loss ($48,000)
// Trail: 1.5%
$order = Bingx::trade()->order()
->futures()
->symbol('BTC-USDT')
->buy()
->long()
->type('TRAILING_TP_SL')
->margin(1000)
->leverage(10)
->takeProfitPrice(55000.0)
->stopLossPrice(48000.0)
->trailingStopPercent(1.5)
->execute();
// Scenario 1: Price goes to $60k
// - TP trails to $59,100 (1.5% below $60k)
// - Profit: $9,100 instead of $5,000 (10% more!)
// Scenario 2: Price goes to $55k then drops
// - TP trails to $54,175
// - Still profitable, just less
// Scenario 3: Price drops to $48k
// - Stop-loss hits
// - Loss: $2,000 as planned| Order Type | Best For | Pros | Cons |
|---|---|---|---|
| TRAILING_STOP_MARKET | Protecting profits | Locks in gains, simple | Can get stopped out in volatility |
| TRIGGER_LIMIT | Controlled entries/exits | No slippage, price control | Might not fill |
| TRAILING_TP_SL | Complete automation | Set and forget, combines TP/SL | More complex setup |
| STOP_MARKET | Emergency exits | Always fills | Slippage risk |
| LIMIT | Patient trading | Best price | Might not fill |
// Build position with multiple entries, each with trailing stop
$entries = [
['price' => 50000, 'size' => 0.5],
['price' => 51000, 'size' => 0.3],
['price' => 52000, 'size' => 0.2],
];
foreach ($entries as $entry) {
// Entry order
$order = Bingx::trade()->order()
->futures()
->symbol('BTC-USDT')
->buy()
->long()
->type('LIMIT')
->price($entry['price'])
->quantity($entry['size'])
->leverage(10)
->execute();
// Trailing stop for this entry
$stop = Bingx::trade()->order()
->futures()
->symbol('BTC-USDT')
->sell()
->long()
->type('TRAILING_STOP_MARKET')
->activationPrice($entry['price'] * 1.02) // 2% profit
->callbackRate(1.5)
->quantity($entry['size'])
->execute();
}// Wait for breakout above $52k, then enter with limit
$breakout = Bingx::trade()->order()
->futures()
->symbol('BTC-USDT')
->buy()
->long()
->type('TRIGGER_LIMIT')
->stopPrice(52000.0) // Breakout level
->price(52100.0) // Enter slightly above
->margin(500)
->leverage(10)
->execute();
// Once filled, set trailing stop
$stop = Bingx::trade()->order()
->futures()
->symbol('BTC-USDT')
->sell()
->long()
->type('TRAILING_STOP_MARKET')
->activationPrice(53000.0) // Let it run to $53k
->callbackRate(2.0)
->quantity(/* size from breakout order */)
->execute();// Buy support, sell resistance, both with limits
// Buy at support ($48k-$49k)
$buySupport = Bingx::trade()->order()
->futures()
->symbol('BTC-USDT')
->buy()
->long()
->type('TRIGGER_LIMIT')
->stopPrice(49000.0)
->price(48500.0) // Try to get better price
->margin(1000)
->leverage(5)
->execute();
// Sell at resistance ($54k-$55k)
$sellResistance = Bingx::trade()->order()
->futures()
->symbol('BTC-USDT')
->sell()
->long()
->type('TRIGGER_LIMIT')
->stopPrice(54000.0)
->price(54500.0) // Try to get better price
->quantity(/* position size */)
->execute();- Don't trail too tight — 0.5% in crypto = noise, you'll get stopped out constantly
- Wait for profit first — Set activation price above entry to lock in gains
- Adjust for volatility — Wider callback in volatile markets
- Use with trends — Works best in trending markets, not ranges
- Leave room — Limit price should be slightly worse than trigger to ensure fill
- Watch the spread — In illiquid markets, gap between trigger and limit matters
- Use for entries — Great for breakout strategies
- Combine with stops — Always have a stop-loss
- Realistic targets — Don't set TP too far, it might never trail
- Proper risk/reward — At least 2:1 reward:risk ratio
- Test first — Complex order, test with small size
- Monitor — Check that both TP and SL are set correctly
// BAD: 0.3% callback in crypto
$order = Bingx::trade()->order()
->type('TRAILING_STOP_MARKET')
->callbackRate(0.3) // Too tight!
->execute();
// GOOD: 1.5-2% for most situations
$order = Bingx::trade()->order()
->type('TRAILING_STOP_MARKET')
->callbackRate(1.5) // Better
->execute();// BAD: Trigger at $50k, limit at $52k
$order = Bingx::trade()->order()
->type('TRIGGER_LIMIT')
->stopPrice(50000.0)
->price(52000.0) // Might never fill!
->execute();
// GOOD: Small gap
$order = Bingx::trade()->order()
->type('TRIGGER_LIMIT')
->stopPrice(50000.0)
->price(50200.0) // Reasonable gap
->execute();// BAD: Trailing stop without hard stop
$order = Bingx::trade()->order()
->type('TRAILING_STOP_MARKET')
->activationPrice(55000.0) // Only trails if profit
->execute();
// If price drops, no protection!
// GOOD: Always have a hard stop
$entry = Bingx::trade()->order()
->type('LIMIT')
->price(50000.0)
->execute();
$hardStop = Bingx::trade()->order()
->type('STOP_MARKET')
->stopPrice(48000.0) // Hard stop at -4%
->execute();
$trailingStop = Bingx::trade()->order()
->type('TRAILING_STOP_MARKET')
->activationPrice(52000.0) // Trails when +4%
->execute();Always test new order types with small amounts:
// Test with minimum size
$test = Bingx::trade()->order()
->futures()
->symbol('BTC-USDT')
->buy()
->long()
->type('TRAILING_STOP_MARKET')
->activationPrice(51000.0)
->callbackRate(2.0)
->quantity(0.001) // Minimum size
->execute();
// Monitor it
$details = Bingx::trade()->getOrder('BTC-USDT', $test['orderId']);
print_r($details);Next: Risk Management — Stay safe with leverage