EA-68535 · Machine Learning

MarketStructure

An ONNX-based Expert Advisor that uses a machine learning model to classify market structure into 4 categories, then places Fibonacci-based pending limit orders when model confidence exceeds a threshold. It combines ML predictions with a 50-period MA trend filter and employs RR-based trailing stops.

Open the interactive view (equity curve, symbol switch)

Key facts

RiskMedium
Blow-up riskLow
Rating★★★☆☆
TypeTrading EA
TimeframesM15, H1, H4
IndicatorsATR, SMA(50), Fibonacci Retracement, ONNX ML Model, Pivot Points, Tick Volume
Author—

Backtest results (H1, about 1 year)

SymbolP&LAnnualMax DDTradesWin rateSharpeRecoveryLosing streakPer tradeStatus
EURUSD0.00%0.00%0.00%0—————Not convertible yet
GBPUSD0.00%0.00%0.00%0—————Not convertible yet
USDJPY0.00%0.00%0.00%0—————Not convertible yet
XAUUSD0.00%0.00%0.00%0—————Not convertible yet

Why this EA never traded: no entry rule survived the conversion.

Converted from MQL5 to Python and run with the same rules for every EA. Positions use MT5 lot sizes (100,000 units per FX lot, 100 oz per gold lot) with 1:100 leverage, one order at a time, and a stop-out below 10% of the starting balance. Sharpe is computed from the equity curve. Results marked as unreliable are shown for completeness only.

Blow-up risk: No blow-up pattern found

None of the usual blow-up patterns were found in the code, and the account was not stopped out in our backtests. That is not a guarantee: any EA can lose money.

High: stopped out in our backtest, or martingale/grid sizing without a stop loss. Elevated: martingale or grid sizing with a stop loss, or several positions at once without a stop loss. What the label means and what we found →

Strategy analysis

The core strategy uses an ONNX model to classify market structure into four categories (labels 0-3), where labels 3 and 2 indicate bullish signals and labels 1 and 0 indicate bearish signals. Entry requires model confidence above a configurable threshold (default 0.65) and alignment with the 50-period MA trend: bullish signals need price above the MA, bearish signals need price below. Entries are placed as pending limit orders at the 0.618 Fibonacci retracement of the last pivot high-low range, with stop loss beyond the pivot plus a 15-point buffer and take profit at a 2x risk-reward ratio. Position sizing uses a fixed lot size with validation against broker min/max lot and lot step constraints. A trailing stop activates when profit reaches 0.8RR, moving the stop to the open price plus 30% of the floating profit distance. Pending orders have a 4-hour expiration.

Strengths

  • Combines machine learning with classical Fibonacci retracement for a multi-layered approach
  • Confidence threshold filters low-quality signals, preventing blind entries
  • Uses limit orders instead of market orders for better entry prices
  • RR-based trailing stop and pending order expiration provide solid risk controls
  • New bar check prevents duplicate signals on the same candle

Weaknesses

  • ONNX model is a black box — strategy reliability depends entirely on model quality with no way to audit training or generalization
  • InpWindowSize parameter is declared but never used in the code, creating dead code
  • Pivot identification only looks back 100 bars with a fixed window of 5, may fail to find valid pivots in volatile markets
  • Trailing stop only locks in 30% of floating profit, which is weak protection and may give back too much in large swings
  • No spread filter or slippage protection — limit orders may fill at unfavorable prices in low-liquidity environments
  • GetLastPivot loop may access out-of-range bars when i+5 exceeds available history

Possible improvements

  • Add spread and volatility filters to avoid trading during high-spread or low-liquidity periods
  • Make the trailing stop lock-in percentage configurable and consider a step-trailing approach
  • Fix potential array out-of-bounds in GetLastPivot by adding Bars() boundary checks
  • Remove unused InpWindowSize parameter or actually incorporate it into feature calculation
  • Add detailed logging for ONNX model load failures to aid troubleshooting

Risk assessment

Overall risk: Medium

  • ONNX model is a black box with no protection against model degradation or failure
  • GetLastPivot may access out-of-range bars returning 0, triggering invalid pending orders
  • No spread filter means limit orders may fill at unfavorable prices during volatile periods
  • Only 1 open position and 0 pending orders allowed simultaneously, potentially missing consecutive opportunities

Evaluation scores

Code quality3.0
Strategy logic3.0
Risk management3.0
Robustness2.0
Innovation4.0
Documentation1.0
Overall2.7

Parameters

ParameterDefaultDescription
InpModelNamemarket_structure.onnxONNX model file name
InpThreshold0.65AI prediction confidence threshold
InpWindowSize5Window size (unused)
InpLotSize0.1Initial lot size
InpFibLevel0.618Fibonacci retracement level
InpRR2.0Risk-reward ratio
InpMagic888888EA magic number for identifying positions
InpExpireHours4Pending order expiration in hours
InpTrailingStepRR0.8Trailing stop trigger RR threshold

Similar Machine Learning EAs

Backtests are historical simulations and do not guarantee future results. Not financial advice.

Get the weekly Arena report

One email a week: ranking changes, new signals and new research. No spam; unsubscribe any time.