What do TrailingGapPer and MinProfitLock do?

These two parameters are essential components of Smart TP (Smart Take Profit) in MagicTradeBot. They control how the bot locks profits and when it decides to exit a trade dynamically.


๐Ÿง  TrailingGapPer

Definition: TrailingGapPer sets the maximum allowed pullback percentage from the highest price reached since the trade was opened. Once the price drops by this percentage, the bot executes the take profit.

  • Purpose:

    • Protect profits in a trending market
    • Avoid closing too early while allowing the trade to capture further gains
  • How it works:

    1. Trade moves in your favor โ†’ highest price recorded
    2. Price retraces by TrailingGapPer % โ†’ bot triggers the sell (partial or full)

Example:

TrailingGapPer: 3   # 3% pullback from peak triggers TP
  • Trade rises from $100 โ†’ $110 (peak)
  • Price drops to $106.7 (3% pullback) โ†’ bot closes position

๐Ÿง  MinProfitLock

Definition: MinProfitLock ensures that the bot locks a minimum guaranteed profit before Smart TP can trigger, even if the price temporarily retraces.

  • Purpose:

    • Prevents Smart TP from closing trades too early in minor pullbacks
    • Secures a baseline profit before trailing logic applies
  • How it works:

    • Trade target profit = 5%
    • MinProfitLock = 3% โ†’ bot will not sell below 3% profit even if the price drops temporarily

Example:

MinProfitLock: 4   # Minimum 4% profit must be secured
  • Trade reaches 6% profit
  • Price drops 2% temporarily โ†’ bot does not sell because 4% minimum is not breached
  • If price drops 4% from peak โ†’ triggers Smart TP

๐Ÿ”„ How They Work Together

  1. Price rises โ†’ bot tracks the peak
  2. Price drops โ†’ bot checks:

    • Is drop >= TrailingGapPer?
    • Has minimum profit (MinProfitLock) been secured?
  3. If both conditions are met โ†’ TP executes

Example:

TargetProfitPer: 6
SellPer: 40
EnableSmartTP: true
TrailingGapPer: 3
MinProfitLock: 4
  • Trade rises +6% โ†’ peak recorded
  • Price retraces 3% โ†’ bot checks MinProfitLock
  • Profit above 4% โ†’ bot executes partial sell of 40% of the position

๐Ÿ“Œ Key Points

  • TrailingGapPer โ†’ Defines dynamic pullback threshold for Smart TP
  • MinProfitLock โ†’ Ensures minimum profit is secured before triggering exit
  • Combined, they allow flexible, intelligent profit-taking
  • Fully compatible with partial TP rules and DCA strategies

๐Ÿ“Ž Related Topics