Emergency Close is a critical safety feature in MagicTradeBotโs Intelligent Decision-Making Engine that automatically closes trades during extreme market movements to protect your capital. It acts like a โpanic buttonโ when market conditions suddenly turn against your positions.
๐ง How It Works
Activation
- Controlled via the
EmergencyCloseflag indecision_engine.yaml:
- Controlled via the
EmergencyClose: false # Set to true to enable automatic emergency trade closure
When enabled, all trades flagged for emergency closure are automatically closed when the market triggers the emergency conditions.
Emergency Threshold
- Defined in
market_watch.yamlusingAverageMovementEmergencyClose:
- Defined in
AverageMovementEmergencyClose: 0.6 # % opposite movement to trigger emergency close
Example:
- Crash scenario: Average movement of tracked symbols drops 0.6% downward, marking all long trades with
emergency_close = true - Pump scenario: Average movement spikes upward by 0.6%, marking all short trades with
emergency_close = true
- Crash scenario: Average movement of tracked symbols drops 0.6% downward, marking all long trades with
Minimum Hold Time
- To avoid prematurely closing recently opened trades,
EmergencyCloseMinHoldTimeensures trades are only closed if they have been open longer than a defined duration:
- To avoid prematurely closing recently opened trades,
EmergencyCloseMinHoldTime: 20 # minutes
Trades younger than this threshold are ignored, preventing unnecessary exits from short-lived volatility immediately after entry.
Execution Flow
- Trade is flagged with
emergency_close = truewhen the threshold is met - Decision engine checks the trade age
- If age >
EmergencyCloseMinHoldTime, the trade is closed immediately - If age <
EmergencyCloseMinHoldTime, the trade remains open until the minimum time is reached
- Trade is flagged with
๐ Key Points
- Purpose: Protects your account from rapid market crashes or pumps
- Scope: Can close longs during crashes or shorts during pumps
- Safety Mechanism: Minimum hold time prevents premature exits on recent trades
- Automation: No manual intervention needed; the engine handles emergency closures 24/7
In short, Emergency Close is a proactive risk-management tool that ensures your positions are automatically exited during sharp market reversals, locking in profits or limiting losses without requiring constant monitoring.