How does Maximum Hold Time work for long and short trades?

In MagicTradeBot, Maximum Hold Time is a configurable setting that determines the longest duration a trade can remain open before the bot automatically closes it. This helps prevent trades from lingering too long, reduces risk exposure, and ensures your strategy remains disciplined.

There are separate settings for long and short trades:

MaximumBuyHoldTime: 380   # Maximum hold time in minutes for long (buy) trades
MaximumSellHoldTime: 380  # Maximum hold time in minutes for short (sell) trades

🧠 How It Works

  1. Per-Trade Timing

    • When a trade is opened, the bot starts a timer for that position
    • For long trades, the MaximumBuyHoldTime countdown begins
    • For short trades, the MaximumSellHoldTime countdown begins
  2. Automatic Closure

    • If the trade remains open longer than the configured maximum time and no other exit condition (like Smart TP) applies, the bot will automatically close the trade
    • This prevents trades from running indefinitely and ties up your balance unnecessarily
  3. Interaction with Smart TP

    • If Smart TP Lock is enabled and profit has already been secured:

      • Maximum Hold Time is ignored
      • Trade remains open until price reverses or locked profit conditions are met
    • If Smart TP is not enabled or no profit is locked:

      • Maximum Hold Time acts as a hard exit

🔄 Example Scenarios

Long Trade

  • MaximumBuyHoldTime = 380 minutes (~6.3 hours)
  • Trade opens at $10,000
  • After 380 minutes, if price hasn’t hit Take Profit or Smart TP isn’t active:

    • Bot automatically closes trade
    • Ensures capital is freed for new opportunities

Short Trade

  • MaximumSellHoldTime = 380 minutes
  • Trade opens at $10,000
  • After 380 minutes, if price hasn’t hit Take Profit or Smart TP isn’t active:

    • Bot closes the trade automatically
    • Limits risk of holding a short for too long during market reversal

📌 Why Separate Settings Matter

Long and short trades can behave differently:

  • Long trades may require longer holding in trending up markets
  • Short trades may need quicker exits in volatile downtrends

By having separate Maximum Hold Time values:

  • You can tune each direction independently
  • Optimize strategy for bullish or bearish behavior
  • Control risk and exposure more precisely

🎯 Key Takeaways

  • Maximum Hold Time defines the longest allowed trade duration
  • Separate values for long (buy) and short (sell) trades provide directional flexibility
  • Acts as a hard exit safeguard if other exit rules (like Smart TP) aren’t triggered
  • Helps maintain disciplined trading and prevents overextended positions

📎 Related Topics