market structure onnx

market structure onnx
Download ALL MT5 experts (1593)
YouTube Video Thumbnail



Similar MetaTrader Tools

market structure onnx

Info

The market structure onnx is a Expert Advisor for MetaTrader 5 that backtest xauusd 01/03/2025 - 20/01/2026 timeframe h1 backtest eurusd 01/03/2025 - 21/01/2026 timeframe h1this strategy integrates machine learning-driven market structure classification with rule-based trade execution. an onnx model is employed to categorize the current market structure, while classical technical analysis, including a moving average trend filter, fibonacci retracement, atr, and risk-reward rules, governs entries, exits, and risk management.

Usage

This tool is typically used for automated trading on major forex pairs and gold.

Platform

This Expert Advisor works exclusively on MetaTrader 5 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL5/Experts folder via File ? Open Data Folder in MetaTrader 5.


How to Install and Use market structure onnx

1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.

2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.

3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.

4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.

Frequently Asked Questions

Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.

Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.

Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.

What this tool does

backtest xauusd 01/03/2025 - 20/01/2026 timeframe h1 backtest eurusd 01/03/2025 - 21/01/2026 timeframe h1this strategy integrates machine learning-driven market structure classification with rule-based trade execution.

Typical Use Case

This Expert Advisor excels in automated trading and technical analysis on MetaTrader 5.

Compatible Platform & Setup

This Expert Advisor works on MetaTrader 5. Place the file in the MQL5/Experts folder and restart the terminal.

Description & Settings

Related: Market Miner Expert Advisor - another powerful expert for MetaTrader 5 traders.

backtest xauusd 01/03/2025 - 20/01/2026 timeframe h1 backtest eurusd 01/03/2025 - 21/01/2026 timeframe h1

Also recommended: Real-Time Market Intelligence for Informed Trading Decisions - similar expert with strong performance on MetaTrader 5.


this strategy integrates machine learning-driven market structure classification with rule-based trade execution. an onnx model is employed to categorize the current market structure, while classical technical analysis, including a moving average trend filter, fibonacci retracement, atr, and risk-reward rules, governs entries, exits, and risk management.

the system is engineered to:

- trade exclusively at structurally significant pullback levels

- prevent overtrading by permitting only one active trade or pending order

- utilize probability confidence filtering from the ai model

- implement risk-reward-based trailing stop management


market structure classification using ai

an onnx model (market_structure.onnx) is loaded during initialization. with each new bar, the model predicts the current market structure state.

input features

the model ingests six normalized features:

- momentum change: price difference between the current close and the close 5 bars ago, normalized by atr.

- distance to recent swing high: difference between the highest high in the last 50 bars and the current close, normalized by atr.

- distance to recent swing low: difference between the current close and the lowest low in the last 50 bars, normalized by atr.

- relative tick volume: current tick volume compared to the average tick volume of the last 20 bars.

- candle body strength: difference between close and open price, normalized by atr.

- time feature (hour of day): encodes intraday session behavior.

these features enable the model to deduce trend strength, pullback depth, volatility, volume context, and session timing.


model output and confidence filtering

the onnx model generates:

- a predicted label representing the market structure state (e.g., higher high, higher low, lower high, lower low)

- a probability score for the predicted class

a trade signal is considered valid only if:

- the prediction confidence surpasses the defined threshold (default 0.65)

- the signal aligns with the higher-timeframe trend filter

this ensures that low-confidence or noisy signals are disregarded.


trend direction filter

a 50-period simple moving average (sma) serves as a directional filter:

- bullish bias: price is above the sma

- bearish bias: price is below the sma

trade directions are constrained as follows:

- bullish market structure signals are permitted only in a bullish trend

- bearish market structure signals are permitted only in a bearish trend

this mechanism prevents counter-trend entries.


entry logic using fibonacci retracement

instead of market orders, the strategy employs pending limit orders at fibonacci retracement levels.

pivot detection

recent swing high and swing low are identified using a pivot-based method that scans historical highs and lows.

fibonacci entry

- entry is placed at a predefined fibonacci retracement level (default 61.8%)

- this targets pullbacks within a valid market structure, avoiding breakouts

order types

- buy limit in bullish conditions

- sell limit in bearish conditions

each pending order includes:

- fixed lot size

- stop loss beyond the structure invalidation level

- take profit based on a fixed risk-reward ratio (default 1:2)

- expiration time to prevent stale orders


risk management and trade limitation

the strategy enforces stringent exposure control:

- only one open position or one pending order at a time

- no stacking or martingale behavior

- stop loss is always defined at entry

risk is structurally constrained by:

- market structure invalidation

- atr-normalized distance

- fixed rr ratio


trailing stop based on risk-reward progress

once a position is active, a risk-reward-based trailing stop is applied:

- trailing activates after price reaches a predefined fraction of the tp distance

- stop loss is progressively adjusted toward breakeven and beyond

- trailing logic is symmetric for buy and sell positions

this approach:

- safeguards partial profits

- allows winning trades to extend

- prevents premature stop-outs caused by noise


visual feedback

when a trade setup is created:

- a fibonacci object is drawn on the chart

- the object is automatically removed once all trades and pending orders are cleared

this facilitates visual confirmation of market structure, entry logic, and retracement validity.


summary of the methodology

in summary, this strategy adheres to a hybrid ai + rule-based methodology:

- ai classifies market structure using normalized, context-aware features

- high-confidence predictions are filtered by trend direction

- trades are executed solely at fibonacci pullbacks within the structure

- risk is managed using fixed rr and structural stop placement

- profits are dynamically controlled through rr-based trailing stops

the outcome is a disciplined, structure-driven trading system that leverages ai for decision support rather than automated trading.

You may also like: stealth trade manager: protecting your trades from market volatility - excellent alternative for expert users on MetaTrader 5.

Source Code

#include <trade\trade.mqh>
#property tester_file "market_structure.onnx"
struct onnxprobability {
long  labels[4];
float values[4];
};
input group "ai configuration"
input string    inpmodelname      = "market_structure.onnx";
input double    inpthreshold      = 0.65;
input int       inpwindowsize     = 5;

.......

Leave your opinion, ask a question, share some knowledge

Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.