Local Model Inference Runner
Deploying a model trained outside MetaTrader (in Python, R, or anywhere else) usually means either a DLL bridge, which this catalogue's house rules exclude, or a live server round-trip, which adds a network dependency to every tick. This EA instead parses the model's trained parameters directly from a plain text file and evaluates them itself, entirely in MQL4. Two model kinds are supported, chosen by the file's first line. LOGISTIC carries a comma-separated feature name list, a matching comma-separated weight list, and a bias value; inference is the standard sigmoid(bias + weights . features). TREE carries a feature name list followed by one row per node - a node id, a leaf flag, either a feature index and split threshold (internal node) or a predicted value (leaf), and the left/right child ids; inference walks from the root, following the left child whenever the split feature is less than or equal to the threshold and the right child otherwise, until a leaf is reached. Both model kinds read their inputs from a small fixed vocabulary of live-computed features - moving averages, RSI, ATR, momentum, bar shape and volume - looked up BY NAME against the names the model file itself declares, in the order it declares them, so the file controls which of the supported features it actually needs. A model requesting a feature this EA does not know how to compute is reported plainly, not silently substituted with something else. The resulting score drives a conventional entry: at or above InpBuyThreshold with no position already open opens a buy, at or below InpSellThreshold opens a sell, both sized from account equity and risk percent against an ATR-based stop, exactly like the rest of this catalogue's risk-managed Expert Advisors. Notes and limitations The supported feature vocabulary is intentionally small and fixed; a model trained on features outside this list (raw order-book data, cross-asset series, anything this EA cannot compute from the attached chart alone) cannot be deployed here without first retraining against the supported set. There is no validation that a loaded model was actually trained well, or that its training data resembled the instrument/timeframe it is now being run against - a malformed or overfit model will produce a confident-looking score exactly as readily as a well-trained one, and this EA has no way to tell the difference from inside the terminal. Test any new model file with InpDryRun on for a meaningful stretch before trusting it with live orders.
Expert advisor · MT4 · v1.0 · Free
About Local Model Inference Runner
Local Model Inference Runner is an expert advisor (trading robot) for MetaTrader 4 based on RSI, Moving Average, ATR and Momentum. It can size trades from your balance and risk percent. It has 15 settings, such as Model file name, Buy threshold and Sell threshold. MQL source code included.
Files in the download: LocalModelInferenceRunner.ex4, LocalModelInferenceRunner.mq4, LocalModelInferenceRunner.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Model file name | LocalModelInferenceRunner_Model.txt | File in MQL4\Files\ - see the .txt for the exact format |
| Buy threshold | 0.65 | Logistic: probability at/above this opens a BUY. Tree: predicted value at/above this opens a BUY. |
| Sell threshold | 0.35 | Logistic: probability at/below this opens a SELL. Tree: predicted value at/below this opens a SELL. |
| Ma fast period | 10 | Period or timeframe used by the calculation |
| Ma slow period | 50 | Period or timeframe used by the calculation |
| Rsi period | 14 | Period or timeframe used by the calculation |
| Atr period | 14 | Period or timeframe used by the calculation |
| Momentum period | 10 | Period or timeframe used by the calculation |
| Risk percent | 1.0 | Risk per trade (percent of balance) |
| Stop atr multiple | 1.5 | How much the lot size grows after a loss |
| Target atr multiple | 2.0 | How much the lot size grows after a loss |
| Magic number | 45700 | Magic number that tells this EA's orders apart |
| Dry run | false | true = compute and log the signal, never trade |
| Max retries | 5 | |
| Retry wait ms | 500 |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Buy/Sell Arrows · Risk & Lot Size · RSI · Moving Average · ATR · Momentum · MT4 Expert Advisor · MQL4 Source Code