Overview
The Intelligent Trade Decision Module is an advanced trade management system that automatically closes positions based on configurable rules without relying on exchange-level Stop Loss (SL) or Take Profit (TP) orders. Instead, it monitors trades continuously and makes intelligent exit decisions based on:
- Candle pattern reversals (momentum shifts)
- Time-based threshold rules (dynamic stop-loss)
- Take-profit multiplier rules (scaled profit-taking)
- Global safety limits (emergency exits)
Configuration Structure
1. Main Settings (IntelligentRuleOptions)
IntelligentRuleOptions:
IsEnabled: true # Master switch for intelligent exits
UseOriginalTPAsBase: false # Reserved for future use
EnableAdaptiveThresholds: false # Reserved for future use
MinimumHoldTime: 1 # Minimum minutes before ANY exit (prevents premature closes)
MaximumBuyHoldTime: 20 # Force-close LONG positions after N minutes
MaximumSellHoldTime: 10 # Force-close SHORT positions after N minutes
Key Parameters:
IsEnabled: Set tofalseto disable all intelligent rules and rely on exchange SL/TPMinimumHoldTime: Protects against noise - trade must age this many minutes before rules activateMaximumBuyHoldTime/MaximumSellHoldTime: Ultimate safety - forces exit regardless of profit/loss
2. Candle-Based Exit Rules (Momentum Reversal Detection)
CandleExitRules:
IsEnabled: false # Enable candle pattern exits
OppositesCandlesCount: 2 # Number of consecutive opposite candles to trigger exit
ExitPercentage: 100 # Percentage to close (100 = full exit, 50 = partial)
RuleName: "Momentum Reversal Exit"
RequireMinimumProfit: null # Optional: only exit if profit >= this % (e.g., 2.0)
How It Works:
- LONG trades: Exits when
OppositesCandlesCountconsecutive RED candles appear - SHORT trades: Exits when
OppositesCandlesCountconsecutive GREEN candles appear - Use Case: Catch quick momentum reversals before they become losses
Example:
# Exit 50% of position after 3 consecutive red candles (for longs)
CandleExitRules:
IsEnabled: true
OppositesCandlesCount: 3
ExitPercentage: 50
RequireMinimumProfit: 1.5 # Only trigger if already in 1.5%+ profit
3. Threshold Rules (Time-Based Stop Loss & Profit Protection)
Threshold rules activate at specific time intervals and close trades if profit/loss crosses thresholds.
Long Trade Thresholds
LongTrade:
ThresholdRules:
- Minutes: 30 # After 30 minutes
ThresholdPer: -80.0 # Close if loss >= 80% (STOP LOSS)
RuleName: "Quick Stop Loss - Long"
- Minutes: 360 # After 6 hours
ThresholdPer: -60.0 # Close if loss >= 60% (tighter SL)
RuleName: "Extended Stop Loss - Long"
- Minutes: 720 # After 12 hours
ThresholdPer: -50.0 # Close if loss >= 50% (profit protection)
RuleName: "Profit Protection - Long"
Short Trade Thresholds
ShortTrade:
ThresholdRules:
- Minutes: 15
ThresholdPer: -30.0 # Tighter SL for shorts (more volatile)
RuleName: "Quick Stop Loss - Short"
- Minutes: 60
ThresholdPer: -20.0
RuleName: "Tight Stop Loss - Short"
- Minutes: 180
ThresholdPer: -15.0
RuleName: "Profit Protection - Short"
Interpretation:
- Negative values = Stop-loss protection (close if profit drops below threshold)
- Positive values = Profit lock-in (close if profit falls back to threshold)
- Rules are cumulative - all applicable rules are checked at each interval
4. Take-Profit Rules (Scaled Profit-Taking)
Take-profit rules sell portions of your position as profit milestones are reached, based on multipliers of your original TP target.
LongTrade:
TakeProfitRules:
- TpMultiplier: 0.2 # At 20% of original TP (e.g., 10% TP → trigger at 2%)
SellPer: 100 # Sell 100% of position
RuleName: "10% Target - Long"
IsEnabled: true
UseMarketOrder: true
Example with Multiple TP Levels:
# Assume your original TP target is 10%
TakeProfitRules:
- TpMultiplier: 0.5 # Triggers at 5% profit (0.5 × 10%)
SellPer: 25 # Sell 25% of position
IsEnabled: true
- TpMultiplier: 1.0 # Triggers at 10% profit (1.0 × 10%)
SellPer: 30 # Sell 30% more (now 55% total sold)
IsEnabled: true
- TpMultiplier: 2.0 # Triggers at 20% profit
SellPer: 25 # Sell 25% more (now 80% sold)
IsEnabled: true
- TpMultiplier: 5.0 # Triggers at 50% profit
SellPer: 20 # Sell remaining 20% (fully closed)
IsEnabled: true
Key Features:
- Cumulative tracking: System remembers how much has been sold (
tp_sold_cumulative) - Anti-duplication: Each TP level only executes once
- Remaining quantity: Always sells based on remaining position, not original
5. Global Safety Settings
IntelligentGlobalSettings:
MinProfitToEnableTP: 0.0 # Minimum profit % before TP rules activate
MaxLossBeforeForceClose: -30.0 # EMERGENCY: Force-close if loss exceeds this
Parameters:
MinProfitToEnableTP: Prevents TP rules from activating in choppy marketsMaxLossBeforeForceClose: Ultimate protection - overrides all other rules
Decision Priority Flow
The system evaluates rules in this strict order:
- 🚨 Emergency Stop (
MaxLossBeforeForceClose) - Highest priority - ⏳ Minimum Hold Time - Prevents premature exits
- 🕐 Maximum Hold Time - Forces exit after time limit
- 🕯️ Candle Exit Rules - Momentum reversal detection
- ⏱️ Threshold Rules - Time-based stop-loss/profit protection
- 🎯 Take-Profit Rules - Scaled profit-taking
- ➡️ Continue - No action if no conditions met
Optimized Settings by Trading Style
⚡ Scalp Trading (1-15 minutes)
IntelligentRuleOptions:
IsEnabled: true
MinimumHoldTime: 1 # Very short hold
MaximumBuyHoldTime: 15 # Exit longs after 15 min
MaximumSellHoldTime: 10 # Exit shorts after 10 min
CandleExitRules:
IsEnabled: true
OppositesCandlesCount: 2 # Quick reversal detection
ExitPercentage: 100 # Full exit on reversal
RequireMinimumProfit: 0.5 # Only exit if 0.5%+ profit
LongTrade:
ThresholdRules:
- Minutes: 5
ThresholdPer: -15.0 # Tight stop-loss
- Minutes: 10
ThresholdPer: -10.0
TakeProfitRules:
- TpMultiplier: 0.3 # Quick profit (30% of TP)
SellPer: 50
- TpMultiplier: 0.6
SellPer: 50
IntelligentGlobalSettings:
MinProfitToEnableTP: 0.0
MaxLossBeforeForceClose: -20.0 # Tight emergency stop
📊 Day Trading (15 minutes - 4 hours)
IntelligentRuleOptions:
IsEnabled: true
MinimumHoldTime: 5
MaximumBuyHoldTime: 240 # 4 hours max
MaximumSellHoldTime: 180 # 3 hours max
CandleExitRules:
IsEnabled: true
OppositesCandlesCount: 3
ExitPercentage: 50 # Partial exit on reversal
RequireMinimumProfit: 1.0
LongTrade:
ThresholdRules:
- Minutes: 30
ThresholdPer: -30.0
- Minutes: 120
ThresholdPer: -20.0
- Minutes: 180
ThresholdPer: -15.0
TakeProfitRules:
- TpMultiplier: 0.5
SellPer: 30
- TpMultiplier: 1.0
SellPer: 40
- TpMultiplier: 2.0
SellPer: 30
IntelligentGlobalSettings:
MinProfitToEnableTP: 0.5
MaxLossBeforeForceClose: -35.0
📈 Swing Trading (4 hours - 3 days)
IntelligentRuleOptions:
IsEnabled: true
MinimumHoldTime: 30
MaximumBuyHoldTime: 4320 # 3 days
MaximumSellHoldTime: 2880 # 2 days
CandleExitRules:
IsEnabled: true
OppositesCandlesCount: 5 # More confirmation needed
ExitPercentage: 40
RequireMinimumProfit: 2.0
LongTrade:
ThresholdRules:
- Minutes: 240 # 4 hours
ThresholdPer: -50.0
- Minutes: 1440 # 24 hours
ThresholdPer: -35.0
- Minutes: 2880 # 48 hours
ThresholdPer: -25.0
TakeProfitRules:
- TpMultiplier: 0.5
SellPer: 20
- TpMultiplier: 1.0
SellPer: 30
- TpMultiplier: 2.0
SellPer: 25
- TpMultiplier: 3.0
SellPer: 25
IntelligentGlobalSettings:
MinProfitToEnableTP: 1.0
MaxLossBeforeForceClose: -50.0
🏔️ Long-Term (3+ days)
IntelligentRuleOptions:
IsEnabled: true
MinimumHoldTime: 120 # 2 hours minimum
MaximumBuyHoldTime: null # No time limit (or 43200 for 30 days)
MaximumSellHoldTime: null
CandleExitRules:
IsEnabled: false # Disable - focus on fundamentals
LongTrade:
ThresholdRules:
- Minutes: 1440 # 1 day
ThresholdPer: -60.0
- Minutes: 10080 # 1 week
ThresholdPer: -40.0
- Minutes: 43200 # 1 month
ThresholdPer: -30.0
TakeProfitRules:
- TpMultiplier: 1.0
SellPer: 20
- TpMultiplier: 2.0
SellPer: 20
- TpMultiplier: 5.0
SellPer: 30
- TpMultiplier: 10.0
SellPer: 30
IntelligentGlobalSettings:
MinProfitToEnableTP: 5.0 # Only take profit above 5%
MaxLossBeforeForceClose: -70.0
Demo Mode Support
The system fully supports demo mode where trades are simulated:
General:
demo_mode: true # Enable simulation mode
Demo Mode Features:
- ✅ Calculates theoretical PnL without real exchange orders
- ✅ Tracks partial sells and cumulative profits
- ✅ Logs all decisions with
[DEMO]prefix - ✅ Updates trade state identically to live mode
Best Practices
- Start Conservative
- Begin with wider stop-losses and longer minimum hold times
- Gradually tighten as you understand market behavior
- Test in Demo Mode First
- Always validate new configurations in demo mode
- Monitor decision logs for unexpected behavior
- Layer Your Protection
- Combine candle exits + threshold rules + TP rules
- Each layer catches different failure modes
- Short-Specific Considerations
- Use tighter stop-losses for shorts (more volatile)
- Shorter hold times for shorts (mean reversion risk)
- Lower TP multipliers (avoid greed in bearish moves)
- Monitor
MinProfitToEnableTP- Set above typical spread + fees to avoid loss-making TPs
- Lower for scalping, higher for swing/long-term
- Emergency Stop Distance
MaxLossBeforeForceCloseshould be your "worst case" acceptable loss- Typical: -20% (scalp), -35% (day), -50% (swing), -70% (long-term)
Common Patterns
Aggressive Scalping
MinimumHoldTime: 1
MaximumBuyHoldTime: 10
CandleExitRules: { OppositesCandlesCount: 2, ExitPercentage: 100 }
ThresholdRules: [{ Minutes: 3, ThresholdPer: -10.0 }]
Conservative Swing
MinimumHoldTime: 60
MaximumBuyHoldTime: 7200 # 5 days
CandleExitRules: { IsEnabled: false }
ThresholdRules: [{ Minutes: 1440, ThresholdPer: -40.0 }]
Momentum Scalper
CandleExitRules: { IsEnabled: true, OppositesCandlesCount: 2, ExitPercentage: 50 }
TakeProfitRules: [
{ TpMultiplier: 0.2, SellPer: 50 },
{ TpMultiplier: 0.4, SellPer: 50 }
]
Troubleshooting
| Issue | Solution |
|---|---|
| Trades exit too early | Increase MinimumHoldTime, widen threshold percentages |
| Trades hold too long in losses | Lower threshold percentages, enable candle exits |
| No TP triggers | Check MinProfitToEnableTP, verify multiplier math |
| Candle exits not working | Ensure IsEnabled: true, check candle history is populating |
| Demo PnL incorrect | Verify direction field is correct (Long/Short/Any) |
Monitoring & Logs
The system logs all decisions:
✅ Decision for BTCUSDT: PARTIAL_SELL(25%) - Take profit triggered (Long): 12.50% profit >= 10.00% threshold, selling 25% - Early Profit Taking
📊 Partial TP executed: 25% sold (total: 25%), PnL: 125.40
🏁 Trade FULLY CLOSED for ETHUSDT: Status=Win, Total PnL=543.20
Key Indicators:
- 🎯 Decision type (CONTINUE/CLOSE_ENTIRE/PARTIAL_SELL)
- 📊 Execution confirmations (live mode)
- 🤖
[DEMO]prefix for simulated trades - 🏁 Final closure with PnL summary
Summary
The Intelligent Trade Decision Module provides sophisticated, rule-based trade management that operates independently of exchange-level SL/TP orders. By combining momentum analysis (candles), time-based protections (thresholds), and scaled profit-taking (TP multipliers), it offers flexible, adaptive trade management suitable for all trading styles from scalping to long-term holding.