Â
     QRC4 _ KNN Pivot Predictor Engine
QRC4 brings machine learning directly into MetaTrader 5 no external scripts, no Python environment, no ONNX imports. The entire KNN training pipeline, feature extraction, distance computation, and classification run natively inside the EA on every single bar, across up to eight symbols at once. When the model is confident, it trades. When it isn’t, it waits.
How the KNN Engine Works
K-Nearest Neighbors is one of the most interpretable machine learning algorithms: to classify the current market state, it looks back through recent history, finds the K bars whose feature fingerprint most closely resembles right now, checks whether those bars turned out to be bullish or bearish pivots, and votes accordingly.
QRC4 implements this fully inside MQL5 with three core steps on every new bar, per symbol:
Step 1 -Feature Extraction
Four technical indicators are computed and individually z-score normalized against a rolling window removing scale differences so each feature contributes equally to the distance calculation:
| Feature | Indicator | What it captures |
| F1 | RSI | Momentum overbought/oversold positioning |
| F2 | WaveTrend | Oscillator crossover and cycle position |
| F3 | CCI | Commodity Channel deviation from typical price |
| F4 | ADX | Trend strength separates trending from ranging conditions |
Step 2 – Training Dataset Construction
For each bar in the lookback window, QRC4 reconstructs the same four z-score features at that historical point in time, then looks forward a configurable number of bars to label the outcome: did price go up from there (bullish pivot low) or down (bearish pivot high)? Neutral bars are discarded. This produces a labelled dataset of real market history, rebuilt fresh on every bar.
Step 3 -KNN Classification with Lorentzian Distance
The current bar’s feature vector is compared against every sample in the training dataset. QRC4 uses Lorentzian distance (log(1 + |Δ|) per dimension) rather than standard Euclidean distance this down-weights extreme outlier spikes and produces more stable neighbor selection in noisy financial data. The K closest neighbors vote on the current bar’s classification. The confidence score is the proportion of K votes in the majority direction. Only when confidence clears the minimum threshold does the EA consider placing a trade.
Multi-Symbol Operation
QRC4 runs the full KNN pipeline independently across up to 8 symbols simultaneously from a single EA instance on a single chart. Each symbol maintains its own indicator handles, training dataset, KNN result, cooldown counter, and win rate tracker. A global trade cap limits total open positions across all symbols, and per-symbol trade limits prevent over-concentration on any single pair.
A configurable cooldown period prevents multiple signals firing in rapid succession on the same symbol after a recent trade, reducing overtrading in choppy conditions.
Trade Execution & Management
Position sizing is equity-based, risking a fixed percentage per trade. Stop losses are set as an ATR multiple. The default R:R target is 2.2:1.
Post-entry management follows the standard QRC ladder:
- Partial Close at 1:1 R:R Â locking in nearly 50% of the position
- Breakeven Migration stop moves to entry after the partial close
- Confidence-Driven Scale Engine if a position is running and the KNN model fires again on the same symbol with confidence above the higher scale threshold, a second position is added at reduced risk. If the position draws back beyond the descale trigger, the engine automatically reduces exposure by the configured percentage
Three-Layer Risk Management
| Layer | Function |
| Equity Watchdog | Halts all new entries if live equity drops a defined % below balance |
| Daily Loss Limit | Stops trading across all symbols once the day’s realized loss hits the configured % |
| Max Drawdown Halt | Hard full stop if cumulative peak-to-trough drawdown breaches the ceiling |
Live HUD Dashboard
The dashboard displays a full per-symbol monitor showing: current KNN signal direction, confidence score with visual bar, bull vs bear vote count, average neighbor distance, training set size, and live win rate per symbol all updating every bar. Account balance, equity, floating P&L, open trade counts, and all three risk gauges are displayed alongside the full KNN configuration summary.
Specifications
- Platform: MetaTrader 5
- Recommended Instruments: Up to 8 forex pairs (default: EURUSD, GBPUSD, USDJPY, AUDUSD, USDCAD, NZDUSD, EURGBP, USDCHF)
- Tested on: EUR/USD, GBP/USD, USD/JPY, TimeFrame 1H
- Trading Style: Machine learning, pivot classification, multi-symbol portfolio
- Risk Model: Equity-based percentage risk per trade
- Prop Firm Compatible: Yes (configurable daily loss and drawdown limits)
- Parameters: Fully adjustable K value, training window, forward labelling bars, confidence threshold, all feature periods, scale settings, and all risk limits




Reviews
There are no reviews yet.