44 라인
3.2 KiB
Markdown
[← PosMgmt](./README.md)
| |||
| |||
# PosMgmt - Defines
| |||
| |||
Preprocessor defines that change the behavior of `PosMgmt` (breakeven, partials, conditional partials, trailing stop): extra logs, optional behaviors, calculations and reserves.
| |||
| |||
**How to use them:** define them in your EA **before** the first `#include` of the library, the preprocessor evaluates them when the file is included.
| |||
```mql5
| |||
#define CONDITIONAL_PARTIAL_EXECUTE_WHEN_THE_ARE_POSITIONS
| |||
#include "..\\PosMgmt\\ConditionalPartial\\Main.mqh"
| |||
```
| |||
In the source code a disabled switch appears as `//#define NAME`. The constants are wrapped in `#ifndef NAME`, so your value wins.
| |||
| |||
## Extra logs (all disabled by default)
| |||
| Define | File | Effect |
| |||
|---|---|---|
| |||
| `TSNMQLART_POSMGMT_BE_ELOGS` | `BE\Base\Def.mqh` | Logs of the breakeven classes |
| |||
| `TSNMQLART_PARTIALS_ENABLE_ELOGS` | `Partials.mqh` | Logs of `CBasicPartials` (initialization arrays, tracked positions, partial closes) |
| |||
| `CONDITIONAL_PARTIAL_MORE_INFO` | `ConditionalPartial\Base\Base.mqh` | Extra logs of `CConditionalPartials` |
| |||
| `GENBYLEO_TRAILINGSTOP_DESACTIVE_ERR_LOGS` | `TSL\Basic\TrailingDef.mqh` | **Inverted**: the trailing stop prints error logs by default, defining this **disables** them |
| |||
| |||
## Behavior
| |||
| Define | Default | File | Effect |
| |||
|---|---|---|---|
| |||
| `CONDITIONAL_PARTIAL_EXECUTE_WHEN_THE_ARE_POSITIONS` | off | `ConditionalPartial\Base\Base.mqh` | `Execute(..)` of the condition is called only when there are tracked positions. Off: it is called every time (needed if the condition has to keep its own state, e.g. swing detection) |
| |||
| `TSN_GLOBAL_USE_NEWBAR_MANAGER` | off | `TSL\Manager\Runner.mqh` | The trailing stop runner keeps an index to a global new bar manager instead of its own `CBarControlerFast` |
| |||
| |||
## Calculation
| |||
| Define | Default | File | Effect |
| |||
|---|---|---|---|
| |||
| `MQLART_POSMGMT_BPARTIALS_LOTROUND(number, step)` | `TSNMQLART_ROUND_LOTSIZE_F(MathRound, number, step)` | `Partials.mqh` | Rounding of the volume to close in `CBasicPartials`. **Overridable** |
| |||
| `MQLART_POSMGMT_CONDPARTIALS_LOTROUND(number, step)` | `TSNMQLART_ROUND_LOTSIZE_F(MathRound, number, step)` | `ConditionalPartial\Base\Defines.mqh` | Rounding of the volume to close in the conditional partials. **Overridable** |
| |||
| |||
## Reserves
| |||
Initial reserve of the internal arrays; they grow (double) when full, so these only tune how many reallocations happen.
| |||
| |||
| Define | Default | File | Array | |
| |||
|---|---|---|---|---|
| |||
| `TSNMQLA_TRAILINGSTOP_SWING_DEFAULT_R` | `16` | `TSL\Int\SHL.mqh` | Swing highs / lows of the SHL trailing | **Overridable** |
| |||
| `CBREAKEVEN_RESERVE_ARR` | `16` | `BE\Base\Def.mqh` | Positions of `CBreakEvenBase` (and its remove flags) | **Overridable** |
| |||
| `CPARCIAL_RESERVE_ARR` | `8` | `Partials.mqh` | Tracked positions of `CBasicPartials` | **Overridable** |
| |||
| `CONDITIONAL_PARTIAL_ARR_MAIN_RESERVE` | `16` | `ConditionalPartial\Base\Defines.mqh` | Tracked positions of `CConditionalPartials` (and its remove flags) | **Overridable** |
| |||
| `CONDITIONAL_PARTIAL_SWING_SWEEP_ARR_RESERVE` | `10` | `ConditionalPartial\Conds\Ict\SwingSweep.mqh` | Swing highs / lows of the swing sweep condition | **Overridable** |
| |||
| `TSNMQLA_CTRAILING_STOP_RESERVE_ARR` | `8` | `TSL\Basic\TrailingDef.mqh` | Trailing stops of `CTrailingStop` | **Overridable** |
|