Larry Williams XGBoost Onnx - MetaTrader 5 Expert


Backtesting XAUUSD Timeframe H4 Date Range 24/01/2020 - 03/12/2025
This Expert Advisor (EA) combines the classic Larry Williams out of the bar strategy with artificial intelligence (ONNX) screening. It uses mechanical price action to find setups and artificial intelligence to predict the probability of successful trades.
In order for the EA to initialize correctly, you must place the pretrained machine learning model in the correct directory:
file name: larry_model.onnx (or the name specified in the input).
Trail: MQL5 > Files > larry_model.onnx
Requirement: The EA will not start ( initialization failed ) if this file is missing from the folder.
At the opening of each new bar, the EA checks the outdoor bar (the highest price of the current candle is higher than the previous one, and the lowest price is lower than the previous one).
Bullish signal: Price closes above the previous bar's high.
Bearish signal: Price closes below the previous bar's low.
If an external bar is detected, the EA extracts 10 data features (body size, relative range, ATR, volume change, day of the week, hour, etc.) and sends them to the larry_model.onnx model.
The EA executes a buy if the AI probability of category 1 (buy) > InpThreshold.
The EA executes sell if AI probability of category 2 (sell) > InpThreshold.
Stop Loss (SL): Placed at the lowest price (buy) or the highest price (sell) of the signal candle.
Take profit (TP): automatically calculated based on the InpRR ratio.
Frequency: The EA only allows one open position at a time .
If you use Python (Scikit-Learn, PyTorch, etc.) to train the model, make sure the output meets the EA requirements:
Input shape: {1, 10} (10 features).
Output node 0: predicted label (long).
Output node 1: Probability (floating point array with 3 categories: [Neutral, Buy, Sell]).
Function order: Data must be provided in the exact order defined in the CalculateFeatures function (body size, relative range, bull/bear signs, ATR, Rel ATR, day, hour, volume change, forward direction).
Unzip larry_william.zip
Run the command pip install -rrequirements.txt
First open Metatrader 5
Run python download_csv_metatrader5.py
Run python train_larry_williams.py
Run python Convert_onnx_larry.py
Attachment download
📎 larry_model.onnx (4120.09 KB)
📎larry_williams_onnx.mq5 (16.38 KB)
Source: MQL5 #68424
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •