# Draggable Trade Panels

**Draggable Trade Panels (Per-Trade Windows)**

* **Purpose:** Provide a per-trade, resizable/draggable window that shows trade details and exposes per-trade quick actions (close, partial-close, move to breakeven, add trailing, edit SL/TP).
* **Creation & Lifecycle:**
  * **Automatic Creation:** Panels are created automatically when you open a trade
  * **Tracking:** Each panel is linked to a specific trade ticket number
  * **Cleanup:** Panels automatically disappear when trades close
* **Panel Content:**
  * **Trade Metadata:**
    * Ticket number (unique identifier)
    * Symbol (pair being traded)
    * Direction (BUY/SELL or pending type)
    * Open price, current price
    * SL/TP levels (if set)
    * Current profit/loss (pips and currency)
    * Trade age (time since entry)
  * **Quick Action Buttons:**
    * **Close** — immediately close the entire position
    * **Half-Close / Partial Close** — close a percentage of your position (default 50%)
    * **Move to BE** — moves your stop loss to breakeven
    * **Add Trailing / Set Trail** — activates trailing stop for this trade
    * **Edit SL/TP** — modify your stop loss and take profit levels
    * **Cancel Pending** — cancels pending orders before they execute
  * **Chart Visualization:**
    * Trade entry marker (arrow or icon)
    * SL line (red horizontal line)
    * TP line (green horizontal line)
    * Entry price line (dashed reference)
    * Performance badge (profit/loss indicator)
    * Optional: swing high/low markers if trade was signal-based
* **Interactions:**
  * Drag: Click-and-drag the panel header to reposition; positions persist in GUI state.
  * Double-click: zooms or toggles advanced detail view (depends on panel config).
  * Buttons: execute immediate actions via the EA's trade manager (close / modify orders).
* **Special Modes:**
  * **Manage Mode Only:** Some panel actions are only available in MANAGE mode to prevent accidental changes during automated trading
  * **Magic = 0 Mode:** Panels can manage manual trades you created outside of BananaEA
* **Best Practices:**
  * **Layout Management:**
    * Use `RearrangeAllWindows` button (dashboard) to organize panels:
      * **Stacked:** vertical stack on right side of chart
      * **Cascaded:** offset diagonal layout for easy access
    * Adjust panel positions manually and they persist via `GUIPositionManager`
  * **Chart Cleanup:**
    * Use dashboard's `ClearChartObjects` button to remove stale visual markers
    * Recommended before live sessions or when switching symbols
    * Does not affect active trade panels, only removes orphaned objects
    * Adjust panel positions manually and they'll stay where you put them
    * Minimize panels when not actively managing (reduces screen space)
    * Close panels for completed trades (auto-cleanup handles this)
    * Limit `MaxOpenTrades` parameter to avoid excessive panel count
