How does the decision engine manage trades after entry?

Once a trade is executed in MagicTradeBot, the Decision Engine takes full control of managing that open position. Trade entry and trade management are handled separately to ensure more accurate, responsive, and reliable decision-making.


๐Ÿ”„ Separate Trade Management Watcher

MagicTradeBot uses a dedicated Decision Watcher that is completely independent from signal generation.

  • Signal system โ†’ Opens the trade
  • Decision Engine Watcher โ†’ Manages the trade after entry

This separation ensures:

  • Faster exit reactions
  • Cleaner logic structure
  • No need to regenerate entry signals to close a trade

๐Ÿ“Œ What Happens After an Order is Placed?

  1. Once an order is executed, it is marked as a running order.
  2. The bot stores a copy of the running trade:

    • In memory (active state)
    • In the database (persistent storage)
  3. If the bot restarts:

    • It reloads all running trades from the database
    • Trade management continues seamlessly
    • No position is lost or unmanaged

This makes the system restart-safe and resilient.


โฑ How Often Are Trades Evaluated?

By default, the Decision Engine Watcher evaluates open trades every:

5 seconds

This means:

  • Every 5 seconds, the engine checks all rules
  • It evaluates:

    • Take Profit logic
    • Smart TP trailing rules
    • Stop-Loss rules
    • Candle-based exits
    • Time-based exits
    • Emergency profit/loss thresholds
  • If any rule condition is met, it executes the appropriate action

โš™๏ธ Adjusting the Decision Interval

You can change how frequently trades are evaluated inside:

/settings/market_data.yaml

Example:

decision_making_interval: 5

๐ŸŽฏ When Should You Change the Interval?

๐Ÿ”ฅ High Volatility / Scalping Strategy

Set interval to 1 second:

decision_making_interval: 1

Best for:

  • Fast-moving markets
  • Tight Smart TP trailing
  • Short-term scalping
  • Aggressive strategies

This allows ultra-responsive exits.


๐Ÿง˜ Long-Term / Swing Trading

Use wider intervals like:

decision_making_interval: 10
decision_making_interval: 15

Best for:

  • Larger timeframes
  • Swing trades
  • Positions that do not require second-by-second adjustments

This reduces system load and unnecessary micro-adjustments.


๐Ÿš€ Why This Architecture Is Powerful

  • Decision processing can be faster than signal generation
  • Exit logic remains responsive even if signal timeframe is large
  • Trades are actively monitored independently of entry signals
  • System is resilient to restarts and crashes

๐Ÿ“Œ Important Notes

  • The decision watcher can operate faster than signal generation
  • It allows responsive exits without generating new signals
  • It ensures continuous monitoring of all open trades

๐Ÿง  In Simple Terms

After a trade opens, the Decision Engine becomes its active manager โ€” checking it every few seconds and deciding whether to:

  • Hold
  • Partially close
  • Fully close
  • Lock profits
  • Exit for safety

It continuously supervises your positions until they are completely closed.

๐Ÿ“Ž Related Topics