Overview
Intelligent exit strategies that adapt to market conditions. Protect profits and minimize losses with rule-based, time-based, and candle-based exit logic combining exchange-level orders with intelligent bot-side decision making.
Architecture
The Smart SL/TP system operates on two levels:
1. Exchange-Level Orders
Traditional stop loss and take profit orders placed directly on the exchange for immediate execution and guaranteed risk management.
2. Bot-Level Intelligence
Advanced monitoring and decision-making engine that watches market conditions and position performance to make dynamic exit decisions beyond simple price triggers.
Exchange-Level SL/TP Configuration
Basic Stop Loss & Take Profit
SLTPSettings:
StopLossPercent: 2.0 # Exit at 2% loss
TakeProfitPercent: 5.0 # Exit at 5% profit
How it works:
- Orders are placed on the exchange immediately after entry
- Stop Loss triggers automatic exit when price moves against you by the specified percentage
- Take Profit triggers automatic exit when target profit is reached
- Executes even if bot goes offline (exchange-guaranteed)
Trailing Stop Loss
SLTPSettings:
EnableTrailingSl: true
TrailingSlOffsetPercent: 0.5
How it works:
- Stop loss "trails" behind the current price as it moves in your favor
- For Long trades: SL moves up as price increases, maintaining the offset distance
- For Short trades: SL moves down as price decreases
- Locks in profits while still giving the trade room to breathe
- Only moves in favorable direction - never moves against you
Example (Long):
- Entry: $100, Initial SL: $98 (2% loss)
- Price rises to $105 → SL moves to $104.475 (0.5% trailing offset)
- Price rises to $110 → SL moves to $109.45
- If price drops, SL stays at $109.45 protecting your profit
Breakeven Protection
SLTPSettings:
EnableBreakeven: true
BreakevenActivationPercent: 1.0 # Activate at 1% profit
BreakevenBufferPercent: 0.2 # Set SL at 0.2% profit
How it works:
- Once price reaches activation threshold, move SL to breakeven (or slightly above)
- Guarantees you won't lose money on a winning trade
- Buffer prevents premature exit from minor retracements
Example (Long): Entry: $100 → Price rises to $101 (1% profit) → SL moves from $98 to $100.20 (0.2% buffer above entry)
Trailing Take Profit
SLTPSettings:
EnableTrailingTp: true
TrailingTpTriggerPercent: 2.0 # Start trailing at 2% profit
TrailingTpOffsetPercent: 0.5 # Trail 0.5% behind peak
How it works:
- Trails your TP target to capture extended runs
- Activates after initial profit threshold is reached
- Follows price at the specified offset distance
- Allows unlimited upside while protecting gains
Example (Long): Entry: $100, TP: $105 (5%) → Price hits $102 (2%) → Trailing TP activates → Price runs to $108 → TP trails to $107.46 → Retrace to $107.46 triggers TP.
Dynamic Trailing Scaling
SLTPSettings:
EnableDynamicTrailingScaling: true
TrailingScalingMap:
"1.0": 0.5
"2.0": 0.4
"3.0": 0.3
"5.0": 0.25
"10.0": 0.2
How it works:
- Trailing offset tightens automatically as profit increases
- Gives early profits room to run while protecting larger gains
- Maximizes risk/reward ratio dynamically
Intelligent Rule-Based Exit Engine
The bot continuously monitors positions and applies sophisticated logic beyond simple price triggers.
Core Intelligence Settings
IntelligentRuleOptions:
IsEnabled: true
UseOriginalTPAsBase: false
EnableAdaptiveThresholds: false
MinimumHoldTime: 1
MaximumBuyHoldTime: 20
MaximumSellHoldTime: 10
How it works: Bot monitors every position in real-time, applies multiple rule types simultaneously, and the first matching rule triggers the exit. Works alongside exchange-level orders for comprehensive protection.
Time-Based Threshold Rules
LongTrade:
ThresholdRules:
- Minutes: 30
ThresholdPer: -30.0
RuleName: "Quick Stop Loss - Long"
- Minutes: 360
ThresholdPer: -20.0
RuleName: "Extended Stop Loss - Long"
- Minutes: 720
ThresholdPer: 10.0
RuleName: "Profit Protection - Long"
How it works: Different loss/profit thresholds apply at different time intervals. Rules are evaluated from shortest to longest time period.
Dynamic Take Profit Rules
LongTrade:
TakeProfitRules:
- TpMultiplier: 0.3
SellPer: 100
RuleName: "Early Exit - Long"
IsEnabled: true
UseMarketOrder: true
How it works: Exit at a fraction of your original TP target. Useful for volatile markets and scaling out positions.
Candle-Based Momentum Exit
CandleExitRules:
IsEnabled: true
OppositesCandlesCount: 2
ExitPercentage: 100
RuleName: "Momentum Reversal Exit"
RequireMinimumProfit: 0.5
How it works: Monitors recent candle patterns for momentum reversal; exits if X consecutive opposite candles appear. Can require minimum profit to avoid premature exits.
Short Trade Configuration
ShortTrade:
ThresholdRules:
- Minutes: 15
ThresholdPer: -30.0
RuleName: "Quick Stop Loss - Short"
- Minutes: 60
ThresholdPer: -20.0
RuleName: "Tight Stop Loss - Short"
TakeProfitRules:
- TpMultiplier: 0.3
SellPer: 100
RuleName: "Max Target - Short"
Key differences from long trades include shorter time windows, tighter management, and quicker exits.
Global Safety Controls
IntelligentGlobalSettings:
MinProfitToEnableTP: 0.0
MaxLossBeforeForceClose: -30.0
MinProfitToEnableTP: Prevents taking profit too early; set to 1.5 to require at least 1.5% profit before TP rules execute.
MaxLossBeforeForceClose: Ultimate safety net overriding all other rules; immediate market exit if reached.
Decision Flow & Priority
- Global Safety Check: MaxLossBeforeForceClose (highest priority)
- Minimum Hold Time: Check if MinimumHoldTime elapsed
- Maximum Hold Time: Force exit if MaximumBuyHoldTime/SellHoldTime exceeded
- Candle Exit Rules: Check for momentum reversal patterns
- Threshold Rules: Evaluate time-based loss/profit thresholds
- Take Profit Rules: Check if TP multiplier targets reached
- Exchange Orders: Fall back to exchange-level SL/TP if no bot rule triggers
First matching rule wins - the bot executes the first exit condition that is met.
Configuration Strategies
Conservative (Capital Preservation)
SLTPSettings:
StopLossPercent: 1.5
TakeProfitPercent: 3.0
EnableTrailingSl: true
TrailingSlOffsetPercent: 0.3
EnableBreakeven: true
BreakevenActivationPercent: 0.5
IntelligentRuleOptions:
MaxLossBeforeForceClose: -10.0
ThresholdRules:
- Minutes: 15
ThresholdPer: -5.0
Aggressive (Profit Maximization)
SLTPSettings:
StopLossPercent: 5.0
TakeProfitPercent: 15.0
EnableTrailingTp: true
TrailingTpTriggerPercent: 5.0
TrailingTpOffsetPercent: 1.0
IntelligentRuleOptions:
MinimumHoldTime: 30
MaxLossBeforeForceClose: -50.0
CandleExitRules:
IsEnabled: false
Balanced (Most Common)
SLTPSettings:
StopLossPercent: 2.0
TakeProfitPercent: 6.0
EnableTrailingSl: true
TrailingSlOffsetPercent: 0.5
EnableBreakeven: true
BreakevenActivationPercent: 1.0
EnableDynamicTrailingScaling: true
IntelligentRuleOptions:
IsEnabled: true
CandleExitRules:
IsEnabled: true
OppositesCandlesCount: 2
MaxLossBeforeForceClose: -25.0
Real-World Example
Setup:
- Entry: $100 (Long)
- SL: 2% → $98
- TP: 5% → $105
- Trailing SL: Enabled (0.5% offset)
- Breakeven: Enabled (1% activation, 0.2% buffer)
- Candle Exit: Enabled (2 red candles)
- Threshold Rule: -20% at 6 hours
Scenario Timeline:
- T+5 min: Price at $101 (1% profit) → Breakeven activates → SL moves to $100.20
- T+15 min: Price at $103 (3% profit) → Trailing SL updates → SL at $102.485
- T+20 min: Price at $104 (4% profit) → Trailing SL updates → SL at $103.48
- T+25 min: Price drops to $102.50 (2.5% profit) → Two consecutive red candles detected → Candle exit rule triggers → Market sell at $102.50 → Result: 2.5% profit captured
Key Benefits
- Layered Protection: Exchange + Bot intelligence working together
- Adaptive Exits: Responds to time, momentum, and price action
- Profit Maximization: Trailing mechanisms capture extended moves
- Loss Minimization: Multiple stop mechanisms prevent catastrophic losses
- Automation: No manual intervention required once configured
- Flexibility: Separate rules for long/short, day/swing trading styles
- Risk Management: Global safety controls override all other logic
Best Practices
- Start Conservative: Use tighter stops and smaller TPs until you understand your strategy's win rate
- Test Time Thresholds: Adjust Minutes values based on your typical trade duration
- Enable Breakeven: Always protect winners from becoming losers
- Use Candle Rules: Especially effective in trending markets
- Set MaxLoss: Always have an emergency exit threshold
- Monitor Performance: Analyze which rules trigger most often and optimize
- Match Strategy: Scalping needs different settings than swing trading
- Consider Volatility: Wider stops/offsets in volatile markets, tighter in calm markets
Conclusion
The Smart SL/TP system combines the guaranteed execution of exchange-level orders with sophisticated bot intelligence that monitors time decay, momentum reversals, and profit progression. This dual-layer approach ensures you capture profits, minimize losses, and adapt to changing market conditions automatically - allowing you to trade with confidence while the bot handles the complex exit logic.