Lorentzian Classification EA
- Uzmanlar
-
Michael Prescott Burney
Merhaba, ben Michael P. Burney. Yüksek performanslı algoritmik işlem sistemleri konusunda uzmanlaşmış profesyonel bir trader, trading koçu ve Expert Advisor (EA) geliştiricisiyim. Yıllar süren gerçek piyasa deneyimiyle değerli metaller piyasasında kendimi kanıtladım; zararlar, düşüş dönemleri ve - Sürüm: 1.0
- Etkinleştirmeler: 5
Lorentzian Classification EA for MetaTrader 5
Lorentzian Classification EA is a machine-learning-based Expert Advisor for MetaTrader 5 designed to classify market conditions and automate trade execution using a structured confirmation process. It combines Lorentzian Distance K-Nearest Neighbors (KNN) classification with kernel regression trend confirmation, then applies multiple market filters and configurable trade management rules before opening a position.
The system was built for traders who want a more adaptive, data-driven approach than fixed-rule indicators alone. Instead of relying on a single signal source, the EA evaluates a multi-feature market state, compares it to historical patterns, and uses confluence logic to reduce weak or low-quality entries.
Core idea behind the system
At the center of the EA is a Lorentzian Distance classifier. For each new closed bar, the system builds a feature vector from technical measurements such as RSI, WaveTrend, CCI, and ADX, then compares the current market state to historical data in order to find similar patterns. Based on how those similar patterns resolved in the past, the classifier produces a directional prediction score.
The Lorentzian Distance approach is used because it compresses large feature differences more gracefully than standard Euclidean distance. In practical terms, this makes the similarity calculation more resistant to outliers and volatility spikes that often distort financial data.
The KNN engine can scan up to 2,000 historical bars, evaluate neighbors using the Lorentzian metric, and generate a bullish or bearish vote based on the outcomes of the nearest historical matches. The resulting prediction score helps determine whether current conditions favor a long or short setup.
Kernel regression confirmation
To avoid acting on raw classification output alone, the EA includes a kernel regression confirmation layer. It uses Rational Quadratic and Gaussian kernel estimates to evaluate trend alignment and to confirm whether a KNN signal is supported by the current directional structure of the market.
If the kernel filter is enabled, long signals require bullish kernel alignment and short signals require bearish kernel alignment. This extra confirmation step is intended to reduce false signals, especially during ranging or unstable conditions.
The same kernel logic can also be used for dynamic exit management. When enabled, trades may be closed based on kernel crossover behavior instead of using only a fixed holding model.
Feature-driven market classification
The EA supports up to five simultaneous features in its classification model. The default configuration uses RSI, WaveTrend, CCI, ADX, and a second RSI with different settings so the algorithm can analyze momentum, deviation, cycle behavior, and trend strength from multiple angles.
Each feature is configurable, allowing the user to tailor the behavior of the classifier to different symbols and timeframes. This makes the EA suitable for traders who want to keep the default research-based structure while still being able to optimize the input profile for their own market selection.
Because the feature set is part of the similarity calculation, changing feature periods or types directly affects how the system interprets historical market states. This gives advanced users room to perform optimization and walk-forward validation without changing the overall architecture of the strategy.
Filter stack for trade quality
After the classifier generates a directional bias, the signal must pass through a configurable filter stack before a trade can be opened. Available filters include a volatility filter, regime filter, ADX filter, EMA trend filter, SMA trend filter, session filter, spread filter, and kernel filter.
The volatility filter is designed to block trades during abnormal spikes, while the regime filter helps distinguish trending conditions from flat market structure. The EMA and SMA filters can be used to keep trades aligned with the broader trend, and the ADX filter can restrict entries to periods with sufficient directional strength.
This layered structure is useful because one condition alone is rarely enough in live markets. The EA is designed so that classification, trend alignment, volatility control, and execution filters can work together rather than depend on a single trigger.
Trade management flexibility
Lorentzian Classification EA includes both basic and advanced trade management options. Users can select fixed lot sizing or risk-based sizing, choose ATR-based or fixed stop loss and take profit models, limit the number of open positions, and define a unique magic number for each chart instance.
Advanced controls include trailing stop, breakeven, partial close, and maximum spread protection. These options make it possible to configure the EA for more aggressive execution, balanced swing trading, or more conservative capital-preservation workflows.
The stop and target framework is designed to adapt to different environments. ATR-based stops can respond to changing volatility, while fixed-pip settings remain available for traders who prefer simple and fully deterministic trade management.
Included set file profiles
The EA is delivered with seven pre-configured set file profiles to provide structured starting points for different trading styles and time horizons. These profiles include M15 Scalping, M30 Intraday, H1 Swing, H4 Position, D1 Long-Term, H1 XAUUSD Gold Specialist, and H4 Conservative / Prop Account.
The H4 Position profile is the primary recommended starting point because the underlying Lorentzian framework was originally designed and tested around higher intraday to swing-style timeframes. The other profiles are intended for traders who prefer faster execution, gold-specific tuning, long-term trend participation, or lower-risk funded-account style operation.
These profiles are not presented as fixed final settings. They are designed as structured baselines that traders can further test and refine for their own broker conditions, symbols, and execution style.
How entries are generated
A buy setup requires a positive classification outcome and confirmation from all enabled filters. Depending on the current configuration, this can include trend alignment with EMA or SMA filters, acceptable spread conditions, valid trading session timing, and bullish kernel confirmation.
A sell setup follows the same logic in the opposite direction. The EA also checks that the signal is new rather than a continuation of the previous state, which helps prevent repetitive entries from the same directional bias.
Exits can be handled through fixed trade duration logic, kernel-based dynamic exits, stop loss, take profit, trailing stop, breakeven, or partial close behavior. This makes the execution model adaptable without requiring changes to the signal-generation engine itself.
Chart dashboard and visual tools
The EA includes an on-chart dashboard that displays the current signal state, prediction score, kernel trend status, filter pass/fail conditions, feature values, spread information, position details, and internal trade statistics tracked since startup.
Optional signal arrows can also be displayed on the chart to make historical entries easier to review visually. These elements are intended to help traders understand why a trade was or was not taken and to simplify testing, validation, and ongoing parameter review.
For VPS or optimization environments, the dashboard can be disabled to reduce visual overhead. The display layer is informational and does not change the trading logic itself.
Backtesting and optimization use
The EA was documented with backtesting and optimization in mind. It is intended to be tested in MetaTrader 5 using "Every tick based on real ticks" so that traders can evaluate the classifier, filters, and trade management logic under more realistic simulation conditions.
The manual also outlines a phased optimization workflow covering feature tuning, neighbor count, filter calibration, and ATR-based trade management refinement. This is especially useful for traders who want to adapt the EA to specific pairs without optimizing every parameter at once.
Walk-forward analysis is strongly recommended when refining settings. The goal is not simply to find attractive backtest results, but to identify parameter combinations that remain stable when tested on unseen market data.
Who this EA is built for
This Expert Advisor is suitable for traders who want a structured, research-driven system that blends machine-learning classification with practical market filters and configurable execution management. It can be used by traders who prefer automated operation, as well as by advanced users who want a framework they can study, optimize, and deploy across multiple pairs or timeframes.
The included profiles cover everything from lower-timeframe execution to higher-timeframe position trading, including a dedicated XAUUSD profile and a conservative funded-account style profile. This gives the product flexibility without forcing every user into the same setup.
Main features
- Lorentzian Distance KNN classification engine for pattern-based directional analysis.
- Kernel regression confluence using Rational Quadratic and Gaussian estimators.
- Configurable feature pipeline with RSI, WaveTrend, CCI, and ADX inputs.
- Multi-layer filter stack including volatility, regime, ADX, EMA, SMA, session, spread, and kernel filters.
- ATR-based or fixed-pip stop loss and take profit management.
- Optional trailing stop, breakeven, and partial close functions.
- Risk-based lot sizing and support for multiple deployment profiles.
- Seven pre-configured set files for different styles, symbols, and risk preferences.
- On-chart dashboard with signal state, filter status, feature values, and trade statistics.
- Designed for systematic backtesting, phased optimization, and walk-forward validation.
Important usage notes
- The EA requires historical data to warm up the classification engine before signals can be generated.
- Different brokers, spreads, execution speed, and symbol specifications can affect live behavior compared with tester results.
- For lower timeframes and gold trading, broker quality and spread control are especially important.
- Unique magic numbers should be used when running multiple instances on the same account.
- Demo testing and forward validation are recommended before live deployment.
