Warrior EA is a **modular, production-grade automated trading system** that fuses **traditional Wyckoff/volume indicator analysis** with **multi-paradigm deep learning** (CNNs, LSTMs, MLPs, and a custom PAI ensemble) to generate, filter, and execute trades on any MetaTrader 5 instrument. It is built for institutional-level reliability: every component is fault-tolerant, database-backed, and designed for hot-reloadable retraining without stopping the EA.
| `CNeuronBaseOCL` / `CNeuronConvOCL` / `CNeuronPoolOCL` / `CNeuronLSTMOCL` | Accelerated versions — these drive the DirectML and CPU-DLL tiers too, not only OpenCL |
| `CNeuronBatchNormOCL` | Batch normalization, as its own layer between dense pairs |
#### Compute Backend (4-Tier Fallback)
The system selects the best available compute backend at construction:
| **CSignalITF** | "Institutional Trade Flow" — non-ML. Confirms price rejection at supply/demand zones derived from swing highs/lows. Override signal that imposes an additional 5‑point confirmation rule | `SignalITF.mqh` |
### Signal Base Class (`CExpertSignalAIBase` in `Expert/ExpertSignalAIBase.mqh`)
Every ML signal shares this base which handles:
- **Topology construction** via introspective loop: takes `m_neuronsCount` (neurons per layer) and `m_layersCount` (number of layers), builds tapering hidden layers
- **Input buffer management:** 90+ features collected from indicators + price action + macro filters
- **Async training:** `TrainSingleStep()` runs in `OnTimer()`, writing to DB via `SaveSignalWeights()` and `SaveSignalStats()`
- **Long-term / short-term prediction modes** with configurable bars lookback
### Filter Signals (Gatekeepers)
| Filter | Purpose |
|---|---|
| **CSignalNewsFilter** | Blocks trading during high-impact news events. Maintains a `NewsCache` over an `N_DAYS` window. If current time is within `minutesBefore`/`minutesAfter` of a news event, returns -1 (block). Has override force-open flag | `SignalNewsFilter.mqh` |
| **CSignalSessionFilter** | Restricts trading to user-defined active sessions (e.g., London, NY, Tokyo). Configurable start/end times per session | `SignalSessionFilter.mqh` |
### Signal Aggregation (`Signals.mqh`)
The `CSignals` class **composes all 7 signal modules**:
// Step 3: Composite via confidence bridge + indicator confirmation
composite = 0.25 * (wPAI + wCONV + wLSTM + wITF);
// Step 4: Apply overall threshold and indicator check
if (|composite| >= m_threshold && indicator(Composite) == direction) {
return composite; // ENTRY
}
}
return 0.0; // NO ENTRY
}
```
Each model is trained **independently and asynchronously** — the system saves/loads weights per-model via the database. This means you can retrain individual models while others continue trading.
---
## 5. Custom Indicators (`CustomIndicators/`)
Seven "AD" (AnimateDread) indicators provide the **feature engineering layer**:
| Indicator | What It Measures |
|---|---|
| **ADZigZag** | Swing high/low detection with configurable depth/deviation/backstep. Used for ITF zone calculation | `ADZigZag.mq5` |
| **ADWyckoffFailedStructure** | Detects failed Wyckoff patterns (Spring failure, Upthrust failure, SOS failure) as reversal signals | `ADWyckoffFailedStructure.mq5` |
| **ADWyckoffSignificantBarInversion** | Identifies Significant Bar Inversions — wide-range bars that reverse the prior swing direction, key Wyckoff turning points | `ADWyckoffSignificantBarInversion.mq5` |
These indicators **feed into the neural network input layer** (~90 features total), providing the raw "market microstructure" data that the AI learns from.
---
## 6. Database Layer (`Database/`)
A complete **fault-tolerant SQLite persistence layer** with 5 manager classes:
| **CExpertSignalAIBase** | Base class for all ML signal modules. Topology builder, training loop, async weight save/load |
### Trading Flow (OnTick → OnTimer)
```
OnTick():
├── Check scheduled close time → close all if match
├── Call CExpertSignalCustom.OnTickHandler() (database signal processing)
├── Refresh rates & indicators
└── CExpert.Processing():
├── Check reverse → close opposite positions
├── Check open positions → trailing stop
├── Check pending orders → delete / trail
└── Check entry → if signal threshold met → open order
OnTimer():
└── ProcessBufferedSignals():
├── Load indicator features
├── For each model (PAI, CONV, LSTM):
│ ├── TrainSingleStep()
│ ├── SaveSignalWeights()
│ └── SaveSignalStats()
├── UpdateSignalsWeights() (hot-reload from DB)
└── CloseDB() when not backtesting
```
---
## 9. Trailing Stops (`Trailing/`)
| Strategy | Logic | File |
|---|---|---|
| **CTrailingATR** | Trail stop at `N × ATR` from current price. Updates every bar when new high/low extends. Configurable `m_atrPeriod`, `m_atrMultiplier` | `TrailingATR.mqh` |
Both inherit from `CTrailing` base with `CheckTrailingStop()` checking long/short positions independently.
---
## 10. Control Panel (`Panel/`)
A **CAppDialog-based floating GUI** that runs in the chart window. Controls include:
- Model status indicators (PAI / CONV / LSTM trained/loading/error)
- Manual train/retrain buttons per model
- Signal confidence display (real-time bars for long/short)
- Live P&L dashboard
- Session filter toggle
- News filter override
- Database connection status
---
## 11. DirectML C++ Integration (`DirectML/`)
Two native Windows DLLs compiled from C++:
| DLL | Source | Purpose |
|---|---|---|
| `WarriorCPU.dll` | `WarriorCPU.cpp` | Pure CPU inference. Uses Eigen-like matrix ops. Fallback tier 3 |
| `STOP_LOSS_MODE`, `TAKE_PROFIT_MODE` | ATR presets + Intelligent; these also define the **triple-barrier training target**, not just order placement |
| `MONEY_MANAGEMENT_STRATEGY`, `TRAILING_STRATEGY` | lot-sizing and trail selection |
| `CONFIDENCE_SOURCE` | AI / DB / blended confidence (see `Variables/ConfidenceBridge.mqh`) |
| `MA_TYPE_PRESETS` | the 9 types of the unified `ADMovingAverage` indicator |
| **NewBar** | Detects new bar formation via `Volume` change. Calls `RefreshRates()`, returns `true` once per new bar. Critical for not re-trading the same bar | `NewBar.mqh` |
| **AtomicFile** | Crash-safe binary writes: stage to a `.savetmp`, publish with an atomic `FileMove`. Used by the `.nnw` and every sidecar (`.stats`, `.arrows`, `.cfg`) | `AtomicFile.mqh` |
| **ConfidenceBridge.mqh** | Maps model raw output to trading confidence. `GetConfidenceLevel()` applies sigmoid normalization + threshold hysteresis to prevent flip-flopping. Maintains per-model confidence history |
| **IndicatorTuneRanges.mqh** | Defines min/max tuning ranges for each indicator parameter. Used by the optimization runner to constrain search space |
---
## 15. Complete Trading Flow (End-to-End)
```
1. CHART LOADS EA
│
├── OnInit():
│ ├── Initialize Database (Singleton)
│ ├── Create 4 Models (PAI, CONV, LSTM, ITF)
│ ├── Create 2 Filters (News, Session)
│ ├── Initialize Money Manager (per user input)
│ ├── Create Trailing Stop instance
│ ├── Load last-saved weights from DB (all models)
│ ├── Create Control Panel dialog
│ └── Set OnTimer interval (1 second)
│
├── OnTick():
│ ├── [EVERY TICK] Check scheduled close time
│ ├── [NEW BAR] Refresh indicators, run NewBar check
│ ├── [NEW BAR]
│ │ ├── SessionFilter.Check() → block if outside hours
│ │ ├── NewsFilter.Check() → block if news pending