API v3 introduces new order types that give you more control over your trades. Let's break them down. ## Trailing Stop Market 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. ### How It Works **For Long Positions:** 1. Set activation price (when trailing starts) 2. Set callback rate (how far behind to trail) 3. Price hits activation → trailing begins 4. Price goes up → stop follows at callback distance 5. 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 ### Basic Usage ```php $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(); ``` ### For Short Positions ```php $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(); ``` ### Choosing Callback Rate **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 ### Real Example ```php // 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! ``` --- ## Trigger Limit 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. ### Why Use It? **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 ### Basic Usage ```php $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:** 1. Price drops to $49,500 → order triggers 2. Limit buy order placed at $50,000 3. Order fills when price reaches $50,000 or better ### Stop-Loss with Trigger Limit ```php // 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 ### When to Use **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 --- ## Trailing TP/SL Combined trailing take-profit and stop-loss in one order. Set both your profit target and stop-loss, with trailing on the TP side. ### Basic Usage ```php $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 ### Real-World Example ```php // 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 ``` --- ## Comparison Table | 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 | --- ## Advanced Strategies ### Pyramid with Trailing Stops ```php // 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(); } ``` ### Breakout with Trigger Limit ```php // 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(); ``` ### Range Trading with Trigger Limits ```php // 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(); ``` --- ## Tips & Best Practices ### Trailing Stops 1. **Don't trail too tight** — 0.5% in crypto = noise, you'll get stopped out constantly 2. **Wait for profit first** — Set activation price above entry to lock in gains 3. **Adjust for volatility** — Wider callback in volatile markets 4. **Use with trends** — Works best in trending markets, not ranges ### Trigger Limits 1. **Leave room** — Limit price should be slightly worse than trigger to ensure fill 2. **Watch the spread** — In illiquid markets, gap between trigger and limit matters 3. **Use for entries** — Great for breakout strategies 4. **Combine with stops** — Always have a stop-loss ### Trailing TP/SL 1. **Realistic targets** — Don't set TP too far, it might never trail 2. **Proper risk/reward** — At least 2:1 reward:risk ratio 3. **Test first** — Complex order, test with small size 4. **Monitor** — Check that both TP and SL are set correctly --- ## Common Mistakes ### ❌ Trailing Stop Too Tight ```php // 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(); ``` ### ❌ Trigger-Limit Gap Too Wide ```php // 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(); ``` ### ❌ No Stop-Loss ```php // 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(); ``` --- ## Testing Your Orders Always test new order types with small amounts: ```php // 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](Risk-Management.md) — Stay safe with leverage