Lexicon Pattern
- Experts
- Konstantin Chechnev
- Version: 1.0
Lexicon Pattern analyzes sequences of closed candles and uses their statistics for automated trading in MetaTrader 5. The default configuration is intended for EURUSD M5.
On the first processed tick of a new bar, the Expert Advisor chooses to buy, sell, or skip entry (ABSTAIN). When algorithmic trading is enabled and the conditions are met, it submits a market order with Stop Loss and Take Profit.
Main features
- Candle classification. Each closed bar is assigned to one of eight structural states. The calculation considers range, body, wicks, closing position, and overlap with the previous bar. Comparisons use earlier data, without future candles.
- Adaptive memory. The model learns sequences of different lengths and assesses their information content against a model without memory. Shorter contexts are used when observations are insufficient.
- Virtual scenarios. For each ready context, buy and sell scenarios are tracked separately until the target, stop, or maximum holding period is reached. If both stop and target are touched within one historical candle, the virtual outcome is recorded as a loss. These observations support learning and are not executed trades.
- Entry selection. The model's expected result is assessed against spread, round-turn commission, and a slippage allowance. Context support and recent virtual outcomes are considered. Statistics by broker hour and direction can supplement selection. The Expert Advisor skips entry when data or confirmation is insufficient.
- Execution checks. Before submitting an order, it checks the trading session, spread, loss limits, existing positions, post-exit cooldown, permitted volume, and free margin. New entries are disabled after 20:00 server time on Fridays. Catching up on missing data does not trigger a late entry within a bar already in progress.
Protective levels are sent to the server with the order request. Stop distance accounts for volatility, the broker's minimum distance plus a buffer, and three current spreads. A time-based exit is also provided. If Stop Loss or Take Profit is missing, the Expert Advisor attempts to close the entire position; successful execution depends on the trading server.
Loss recovery is enabled by default and can increase volume after losses. For the next position, it compares the lot size produced by the multiplier with the size calculated to cover the cash deficit, including commissions, swap, and fees. It uses the larger value within the lot-size cap. The cycle is limited by the number of closed positions, and volume by a lot-size cap. At the cycle limit, it resets even if a deficit remains. An unfinished cycle is preserved through a normal restart. These limits do not guarantee that losses will be recovered.
Usage and limitations
Test the Expert Advisor on EURUSD M5 in the Strategy Tester using "Every tick based on real ticks". Set commission and the slippage allowance to reflect the broker's conditions, and allow the model to warm up. After tuning, use a separate historical period and a demo account. Other instruments and timeframes require separate validation.
Lexicon Pattern performs actual trading operations when Algo Trading is enabled. Virtual outcomes, model estimates, and historical tests do not guarantee profits. Increasing lot size after a loss increases potential losses. Quotes, historical data, spread, commission, slippage, gaps, and execution conditions affect results. Stop Loss and restrictions on new entries do not guarantee a maximum loss amount. The user chooses the account, settings, and acceptable risk.
Settings
The values below are defaults. R denotes a unit of calculated stop-based risk, EV the model's expected result, and ATR Average True Range, a measure of volatility. Input-parameter help is available in 11 languages.
History and memory
- Lookback bars: 300 bars for comparing candle ranges. Startup replay: 0, automatic warm-up using closed historical bars.
- Context depth: 7 symbols. Context support: 60 observations. Memory gain: 0.008 bits. These set context depth, minimum support, and the required information content of a sequence.
Statistical selection
- Min EV after costs: 0.05R. Min EV advantage: 0.02R. Thresholds for the expected result after costs and its difference from the opposite direction.
- Quality window: 80 virtual outcomes. Min recent quality: -0.16R. Once the window is full, a deterioration in the assessment can pause actual entries; learning continues.
- SELL quality guard: true. A separate check for sell scenarios using 50 outcomes and a threshold of -0.12R.
- Intraday window: 72 outcomes per hour and direction. Intraday EV weight: 0.00. Zero disables direct blending of estimates, but not the collection of hourly statistics.
- Intraday expansion: true. Minimum hourly EV: 0.20R; relaxation of the main thresholds: 0.01R. Additional entry conditions are applied once hourly statistics are ready.
Position and execution
- Stop: 1.90 ATR(14). Reward/risk: 2.10. Max hold: 16 bars. These set the calculated stop distance, target-to-risk ratio, and maximum holding period.
- Cooldown after Stop Loss and Take Profit: one complete bar each.
- Base lot: 0.01, without automatic scaling to account equity. Allow BUY/SELL: true. Magic Number: 26090301.
- Spread/ATR max: 20%. Trading session: 0–24 server time.
- Round-turn fee/lot: 0 in account currency for opening and closing one lot. Slippage reserve: 10 points. Adjust these cost estimates to the broker's conditions; a zero commission setting does not mean the broker charges no commission.
Limits and volume adjustment
- Daily loss: 10.00. Weekly loss: 16.00 in account currency. Fixed limits on new entries based on the entire account's realized result, including other strategies and manual trades. They do not scale with the deposit and are not floating-loss limits.
- Loss recovery: true. Multiplier: 1.50. Cycle: 3 closed positions, including the initial losing position.
- Lot cap: 0.03. Surplus: 10 points, an addition in the recovery calculation. The cap limits position size but does not guarantee that the deficit will be covered.
Logging and diagnostics
- Export audit CSV: false. Tester diagnostics: false. Log level: NONE. Export and diagnostic messages can be enabled to inspect calculations and trading decisions.
When comparing settings, vary strategy parameters while keeping execution conditions and risk limits the same. Assess the full sequence of trades, costs, and drawdowns, not just the test's final profit.