Loading…

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

SettingDefaultWhat it does
Model file nameLocalModelInferenceRunner_Model.txtFile in MQL4\Files\ - see the .txt for the exact format
Buy threshold0.65Logistic: probability at/above this opens a BUY. Tree: predicted value at/above this opens a BUY.
Sell threshold0.35Logistic: probability at/below this opens a SELL. Tree: predicted value at/below this opens a SELL.
Ma fast period10Period or timeframe used by the calculation
Ma slow period50Period or timeframe used by the calculation
Rsi period14Period or timeframe used by the calculation
Atr period14Period or timeframe used by the calculation
Momentum period10Period or timeframe used by the calculation
Risk percent1.0Risk per trade (percent of balance)
Stop atr multiple1.5How much the lot size grows after a loss
Target atr multiple2.0How much the lot size grows after a loss
Magic number45700Magic number that tells this EA's orders apart
Dry runfalsetrue = compute and log the signal, never trade
Max retries5
Retry wait ms500

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Buy/Sell Arrows · Risk & Lot Size · RSI · Moving Average · ATR · Momentum · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria