141 righe
5,5 KiB
Markdown
# Candle_Pressure_Gold_Silver_EA
| |||
| |||
MetaTrader 5 Expert Advisor. Candle-pressure entries on gold and silver, filtered by market
| |||
context, with hard equity rules implemented in persistent risk state (R-01 v1.2).
| |||
| |||
> This is a source-code repository. The implementation of risk controls described below is
| |||
> **not** evidence of profitability, and it is **not** proof that the equity limits can never
| |||
> be breached under live execution conditions. See *Limitations and status*.
| |||
| |||
## Purpose
| |||
| |||
The EA reads candlestick pressure (body share, wick share and close position inside the bar
| |||
range) and only acts when price sits in a valid context:
| |||
| |||
- higher-timeframe pressure / EMA bias alignment,
| |||
- break of structure (optional),
| |||
- premium or discount inside the dealing range,
| |||
- liquidity sweep (optional),
| |||
- order block or fair value gap touch.
| |||
| |||
Signal quality is gated by a score threshold, ADX trend strength, ATR-relative stops, spread
| |||
cap and a minimum number of bars between entries.
| |||
| |||
## Source structure
| |||
| |||
```
| |||
Candle_Pressure_Gold_Silver_EA/
| |||
├── Candle_Pressure_Gold_Silver_EA.mq5 single-file EA, no project-local includes
| |||
├── README.md
| |||
└── .gitignore
| |||
```
| |||
| |||
The program includes only the terminal-standard library:
| |||
| |||
```cpp
| |||
#include <Trade\Trade.mqh>
| |||
```
| |||
| |||
There is no project-local `Include/` folder, because no project-specific `.mqh` file exists.
| |||
No third-party dependency has to be vendored for the build.
| |||
| |||
## Building in MetaEditor
| |||
| |||
1. Open `Candle_Pressure_Gold_Silver_EA.mq5` from
| |||
`MQL5\Shared Projects\Candle_Pressure_Gold_Silver_EA\` in MetaEditor 5.
| |||
2. Press **F7** (Compile).
| |||
3. Expected result: `0 errors, 0 warnings`.
| |||
The terminal writes `Candle_Pressure_Gold_Silver_EA.ex5` to
| |||
`MQL5\Experts\Shared Projects\Candle_Pressure_Gold_Silver_EA\` (outside this repository).
| |||
4. Attach the EA to an `XAU` or `XAG` chart, or run it from the Strategy Tester.
| |||
| |||
Compiled binaries are not published. `.ex5` is git-ignored.
| |||
| |||
## Risk controls (summary)
| |||
| |||
Position sizing:
| |||
| |||
- risk per trade is bounded by `InpRiskPercentMin` / `InpRiskPercentMax` (0.50% - 1.20% of balance),
| |||
- `InpMaxOpenPositions` limits simultaneous positions,
| |||
- stop distance is ATR-based with a buffer beyond the candle extreme,
| |||
- reward-to-risk target is configurable (default 2.50),
| |||
- `InpMaxSpreadPoints` blocks entries on a wide spread,
| |||
- `InpMaxLotAbsolute` is a hard volume cap; broker minimum-lot override is opt-in only.
| |||
| |||
Hard equity limits (enforced from persistent risk state):
| |||
| |||
- daily maximum loss, default 5% of the day-start equity anchor,
| |||
- static maximum drawdown, default 8% of the frozen initial balance,
| |||
- equity growth target, default 10% of the frozen initial balance,
| |||
- optional close-out and optional EA detach when a limit is hit.
| |||
| |||
Persistent risk state (R-01 v1.2):
| |||
| |||
- a two-slot archive (A/B) with a monotonic sequence number and a checksum,
| |||
- durable write with flush and read-back field verification (R01-H1/H2),
| |||
- one exclusive lock held for the whole provisioning/recovery decision (R01-H7),
| |||
- a persistent provisioning marker whose identity is
| |||
`login|server|risk_scope_id|risk_period_id`,
| |||
- the provisioning snapshot is frozen **before** the archive slots are written,
| |||
- the authorization is consumed exactly once: with a marker present but both archive slots
| |||
gone, provisioning is refused,
| |||
- an interrupted provisioning resumes from the frozen snapshot instead of re-baselining on
| |||
the live balance,
| |||
- a corrupt marker is reconstructed when a valid archive slot survives; a corrupt marker with
| |||
no valid archive is refused.
| |||
| |||
`InpResetRiskState` is a one-shot authorization. It is never applied implicitly, and it is
| |||
ignored when the authorization of the current risk period is already consumed.
| |||
| |||
Documented limit of the mechanism: deleting the marker *and* both archive slots destroys every
| |||
piece of local evidence. A local store cannot detect that and does not claim to.
| |||
| |||
## Implementation status
| |||
| |||
| Item | Status |
| |||
| --- | --- |
| |||
| R-01 persistent risk state | IMPLEMENTED - acceptance gate G2 INCOMPLETE |
| |||
| R-02 | OPEN |
| |||
| R-03 | OPEN |
| |||
| R-04 | OPEN |
| |||
| |||
Acceptance status as reported for the current build. Status is carried forward, not upgraded
| |||
by a build or by publication:
| |||
| |||
| Gate | Status |
| |||
| --- | --- |
| |||
| G1 compile | PASS on the reported build |
| |||
| G2-07 .. G2-10 | PASS with test notes |
| |||
| G2-11 | Regression required on the current build |
| |||
| G2-12 | Regression required on the current build |
| |||
| G2-13 | BLOCKED |
| |||
| G2-14 | BLOCKED |
| |||
| G2-16 | PASS |
| |||
| G2-17 | PASS |
| |||
| G2 overall | INCOMPLETE |
| |||
| |||
Legend: **PASS** has evidence; **FAIL** was executed and failed; **BLOCKED** could not be
| |||
executed because of an obstacle; **NOT TESTED** was never executed; **INCOMPLETE** means the
| |||
gate as a whole is not satisfied.
| |||
| |||
## Limitations and status
| |||
| |||
This repository is a published source snapshot. It is not a claim that:
| |||
| |||
- the 5% daily maximum loss cannot be exceeded in every market condition,
| |||
- the 8% static drawdown is guaranteed under every execution path,
| |||
- a 10% monthly equity growth target is achievable or guaranteed,
| |||
- the EA is ready for live deployment,
| |||
- the EA has a proven profitability edge.
| |||
| |||
Compilation success is not runtime validation. Strategy Tester results are not a guarantee of
| |||
future performance. The risk-state acceptance gate is incomplete, and G2-13 and G2-14 remain
| |||
blocked.
| |||
| |||
## Publication scope
| |||
| |||
Published: EA source (`.mq5`), `.gitignore`, this `README.md`.
| |||
| |||
Not published, by policy and by `.gitignore`: compiled `.ex5`, backtest and tester output,
| |||
logs, runtime risk-state files (`.ack`, `.lck`, archive `.bin`), account identifiers, and
| |||
internal working records under `local_only/`.
|