Take Profit rules in MagicTradeBot’s Decision Engine define how and when a trade should be closed to secure profits. They allow for both full and partial exits, and can be configured for long (buy) and short (sell) trades independently.
These rules are highly customizable and support Smart TP (dynamic trailing logic) to lock profits in volatile markets.
🧠 Structure of TakeProfitRules
A typical configuration in decision_engine.yaml looks like this:
TakeProfitRules:
- TargetProfitPer: 6 # Target profit percentage for this rule
SellPer: 40 # 40% of the position will be sold
RuleName: "Target - Short"
IsEnabled: true # Enable this take profit rule
EnableSmartTP: true # Activate Smart TP for dynamic trailing
TrailingGapPer: 2 # Pullback % before selling triggers
MinProfitLock: 4 # Minimum profit to guarantee before selling
UseDynamicGap: true # Auto-adjust trailing gap based on market
- TargetProfitPer: 6
SellPer: 100 # Full position close
RuleName: "Target - Short"
IsEnabled: true
EnableSmartTP: true
TrailingGapPer: 2
MinProfitLock: 4
UseDynamicGap: true
🔄 How Take Profit Rules Work
TargetProfitPer
- Sets the profit percentage at which the rule may trigger
- Example:
6%→ Rule becomes eligible to execute when price reaches +6%
SellPer
- Defines the portion of the position to sell
- Example:
40%→ Partial profit is taken, leaving remaining position to run
Smart TP (EnableSmartTP)
- Activates dynamic trailing logic
- Protects gains if price starts reversing
- Uses TrailingGapPer and MinProfitLock to maximize secured profit
TrailingGapPer
- Determines the price pullback percentage from peak to trigger sale
- Example:
2%→ If price retracts 2% from its highest point after reaching TargetProfitPer, the bot will sell
MinProfitLock
- Guarantees a minimum profit even if trailing gap triggers early
- Example:
4%→ Ensures at least 4% gain is secured before closing
UseDynamicGap
- Allows bot to adjust trailing gap automatically based on market volatility
- More adaptive than a fixed trailing gap
⚖️ Partial vs Full Take Profit
Partial TP (
SellPer < 100)- Allows locking profits while leaving some position open to capture further gains
- Useful in trending markets
Full TP (
SellPer = 100)- Closes the entire trade once profit target is met
- Useful for conservative or short-term strategies
You can configure multiple Take Profit rules for staggered exits, combining partial and full closure strategies.
📌 Long vs Short Trades
- Take Profit rules can be configured separately for long trades (buy) and short trades (sell)
- This allows precise control over trade management depending on the market direction
🎯 Why Take Profit Rules Are Important
- Ensures structured profit-taking instead of manual exits
- Works with Smart TP to lock profits dynamically in volatile conditions
- Supports partial and full exits for more flexible strategies
- Reduces emotional trading by automating exit decisions
In short, Take Profit rules in MagicTradeBot allow you to define, automate, and optimize trade exits, balancing risk and reward dynamically across both long and short positions.