`HITPositionManagerEA.mq5` is the filled-position manager for positions created by `HITEntryEA.mq5`. It never creates new orders or pending orders. It is a retail hedging account EA and fails initialization on non-hedging accounts.
The managed set is limited to positions whose `POSITION_SYMBOL` equals `_Symbol` and whose `POSITION_MAGIC` equals `input_managed_magic_number`. Multiple tickets, split entries, and simultaneous buy/sell positions are managed independently.
## 2. Indicators
- No standard or custom indicators are used.
- SLTP management uses the current tick, each position's open price, SL, TP, open time, and symbol stop/freeze levels.
- High-volatility stop tightening uses M1/M3/M5/M10/M15 open prices and the current market price.
## 3. Parameters
-`input_managed_magic_number = 10001`: Magic number of positions to manage. It should match the entry EA's `input_entry_magic_number`.
-`input_slippage_points = 10`: Allowed deviation for closes and SL modifications.
-`input_position_close_after_h1_bars = 12`: Time-based close threshold in H1 bars. `0` disables it.
-`input_sltp_manager_enabled = false`: Master switch for SLTP management.
-`input_sltp_show_panel = true`: Shows the SLTP control panel.
- There are no entry conditions because this EA does not create orders.
- On every tick, the EA first evaluates ticket-based time exits and then applies SLTP management.
- Time exits close target tickets when `POSITION_TIME` is older than `input_position_close_after_h1_bars * PeriodSeconds(PERIOD_H1)` by using `CTrade::PositionClose(ticket)`.
- SLTP management applies only candidates that improve the current SL in the profit-protection direction, preserving the current TP with `CTrade::PositionModify(ticket, new_sl, current_tp)`.
- High-volatility stop tightening only accepts candidates that are at or beyond breakeven: at or above entry for BUY positions and at or below entry for SELL positions.
- When `input_sltp_manager_enabled=false`, contradictory detailed SLTP settings do not stop the EA; time exits continue to run. Detailed settings are validated when SLTP management is enabled.
- The production manager EA contains no test-only order creation.
- In the Strategy Tester, `HITPositionManagerTestHarness.mq5` seeds test BUY/SELL positions and a different-magic control position, then calls the same production manager classes.
- Test coverage targets same-symbol/same-magic multi-ticket handling, simultaneous buy/sell positions, magic mismatch exclusion, time exits, and SL updates.
- 2026-06-14: Allowed the EA to continue time-exit management when SLTP master is off even if detailed SLTP settings conflict. Added breakeven protection to high-volatility stop tightening so loss-side SL candidates are discarded.