Trailing Stop Loss
Let your profits run while protecting gains. Our intelligent TSL system follows price movements upward and sells only when the trend reverses.
What is TSL?
Trailing Stop Loss is an intelligent sell strategy that dynamically adjusts your stop-loss price as the market moves in your favor. Unlike a fixed take-profit that sells at a predetermined price, TSL tracks the highest price and sells only when the price drops by a configured percentage from that peak.
Problem with Classic TP
Solution with TSL
Interactive TSL Simulator
Visualize how TSL maximizes your profits
Configuration
Simulation Results
TSL captured additional profit by letting the position run!
Real-World Case Studies
See TSL in action across different market scenarios
Bull Run Scenario
Strong upward trend with gradual profit-taking
Two Operating Modes
TSL Mode (Trailing Stop Loss)trailingStopLossPercentages = [3]
Dynamic stop-loss that follows price upward
{
"buySplits": 3,
"sellPercentages": [10, 20, 30],
"trailingStopLossPercentages": [3, 5, 7]
}Advantages
- Maximizes profits in bull runs
- Automatic adaptation to rising prices
- "Lets profits run" while securing gains
Disadvantages
- May result in lower sell price on quick reversals
- Requires careful drop percentage selection
- Uses MARKET orders (potential slippage)
The Three Phases of TSL
Waiting for Activation
State: tslActive = false
TSL is "armed" but not yet active. System monitors market price and waits for price to reach activation point (TP price).
ATH Tracking
State: tslActive = true, price rising
Each new high updates the ATH and pulls the TSL price upward. TSL price can never decrease, only increase!
Trigger & Sell
State: price <= tslPrice
When price falls to or below TSL price, a MARKET order is placed for immediate exit.
The Formula
Example with 3% Drop: If ATH = $150, then TSL = $150 x 0.97 = $145.50
Time-Based TSL Adjustment
v8.7.0+In real markets, it can be beneficial to adjust the TSL drop over time. Shortly after buying, use a tighter TSL to secure gains. After hours, loosen the TSL to tolerate more volatility.
sellTimeCurves: {
"10": [
{ after: "0", percent: 10, tslPercent: 3 },
{ after: "1h", percent: 10, tslPercent: 5 },
{ after: "4h", percent: 10, tslPercent: 8 },
{ after: "24h", percent: 8, tslPercent: 10 }
]
}Safety Mechanisms
Built-in protections to prevent errors and losses
Minimum TSL Price (Safety Clamp)
TSL will never be set below buy price + 1 tick. This prevents selling at a loss even with high drop percentages.
Notional Check
Before triggering, system verifies the order value meets exchange minimum (e.g., $5). If too small, TSL is permanently disabled.
Race Condition Prevention
Atomic claim mechanism prevents multiple processes from triggering the same sell order simultaneously.
Memory Lock
Additional in-memory lock for legacy compatibility ensures no duplicate processing within the same instance.
TP Mode vs TSL Mode
| Aspect | TP Mode | TSL Mode |
|---|---|---|
| Sell Price | Fixed (TP price) | Dynamic (ATH - Drop%) |
| Profit Potential | Limited to TP | Theoretically unlimited |
| Risk | None (guaranteed TP) | Lower sell on reversal |
| Order Type | LIMIT | MARKET |
| Best For | Sideways markets, quick trades | Bull runs, strong trends |
Log Reference
Understanding TSL log messages
[TSL-INIT]TSL was initialized when order was created
[TSL-ACTIVATED]TSL was activated (price >= activation price)
[TSL-UPDATE]ATH was updated, TSL price pulled up
[TSL-TRIGGER]TSL was triggered (price <= TSL price)
[TSL-SAFETY]Safety clamp was applied
[TSL-RACE-PREVENTION]Double trigger was prevented
[REPRICE-TSL]TSL was adjusted based on time
[TSL-EXECUTION]Market sell order was placed
Ready to Maximize Your Profits?
Configure TSL in your trading bot and let your profits run while protecting your gains automatically.