Split HIT EA into entry and position manager
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# HITPositionManagerEA Specification
|
||||
|
||||
## 1. Overview
|
||||
|
||||
`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.
|
||||
- `input_sltp_use_breakeven`: Standard breakeven.
|
||||
- `input_sltp_use_elapsed_breakeven`: Elapsed-time breakeven.
|
||||
- `input_sltp_use_active_trailing`: Active trailing.
|
||||
- `input_sltp_use_tp_progress_stop`: TP-progress stop.
|
||||
- `input_sltp_use_high_volatility_limit`: High-volatility stop tightening.
|
||||
|
||||
## 4. Entry And Exit Conditions
|
||||
|
||||
- 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)`.
|
||||
|
||||
## 5. Risk Management
|
||||
|
||||
- All position processing uses `PositionGetTicket(i)` followed by `PositionSelectByTicket(ticket)`.
|
||||
- Only positions matching `_Symbol` and `input_managed_magic_number` are touched.
|
||||
- Different magic numbers, different symbols, and manual-position equivalents are ignored.
|
||||
- Logs include ticket, symbol, magic, position type, trade retcode, and `GetLastError()`.
|
||||
- Standard breakeven and active trailing cannot be enabled together; settings validation rejects that conflict.
|
||||
|
||||
## 6. Unit Test Scope
|
||||
|
||||
- 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.
|
||||
|
||||
## 7. Changelog
|
||||
|
||||
- 2026-06-07: Split position-management responsibilities from `HIT-EA_refactor_ver6.mq5` and defined a hedging-account, ticket-based manager EA.
|
||||
Reference in New Issue
Block a user