Skip to content

ML Engine

The ML Engine learns from the strategy's own signals and what followed them, and gives each new signal a probability. Signals below Min probability are not traded. It can also forecast the position size (Quantity mode = ML). It is switched on in General properties; the same engine is available as an indicator - see ML Engine.

ML Engine

Parameter Default What it does
Enable Logging Off Write the engine's log to the Output window and to a log file.
Show Probability On Show probability label on chart.
Show ML panel On Show the ML panel on the chart: the model's state, its recent signals, calibration, live AUC, the models of the ensemble and the size forecast. Sections fold with a click on their title.
Use Metrics Filter Off Block signals if metrics below thresholds.
Use Qty Metrics Filter Off Block quantity forecast if quantity metrics below thresholds.
Use Auto Weights On Auto weight direction models by AUC and F1.
Use Qty Auto Weights On Auto weight quantity models by R2.
Min Probability 0 Probability the engine must give a signal for it to be taken. 0 = automatic threshold.
Top signals (%) 0 Take only the best X % of signals by the model's probability, the boundary measured on its training data. Takes priority over Min Probability. 0 = off.
Bars Ahead 60 Bars ahead used for labeling training samples.
Records Before Retrain 10 How often the model retrains: a training run starts each time this many new labelled samples have accumulated.
Retrain Always Always: the model retrains every Records Before Retrain samples. Until edge: it retrains until its own predictions reach Freeze at AUC, then the model is frozen and no longer changes. Off: no retraining, the saved model is used as it is.
Freeze at AUC 0.56 Until edge: the AUC of the model's own recent predictions (at least 100) at which the model is frozen. 0.5 = a coin flip; 0.55-0.60 is a usable edge.
Label Stop (ticks) 40 Stop distance used to label training signals: a signal counts as a loss if price reaches it first. Independent of the strategy's own stop.
Label Target (ticks) 55 Target distance used to label training signals: a signal counts as a win if price reaches it before the stop within Bars Ahead. Independent of the strategy's own target.
Feature Step (bars) 7 Bars between the points at which the model reads its features.
Feature Points 4 Number of points at which the model reads its features, the signal bar included. More points give more detail but need more data.
Signal Offset Bars 0 How many bars back the signal is read. 0 = the current bar.
Use Quantity Forecast On Activates a model ensemble to forecast the number of contracts per trade
Min Contracts 1 Minimum contracts allowed for quantity forecast.
Max Contracts 10 Maximum contracts allowed for quantity forecast.
Max Qty Step 1 Largest change of size from the previous entry the model sized, in contracts (0 = no limit).

Direction Ensemble Models

Parameter Default What it does
Use LightGbm On Enable LightGbm classifier.
Use FastTree On Enable FastTree classifier.
Use FastForest On Enable FastForest classifier.
Use SDCA LogReg On Enable SDCA logistic regression.
Use LBFGS LogReg On Enable LBFGS logistic regression.
Use Averaged Perceptron On Enable Averaged Perceptron classifier.
Use SGD Calibrated On Enable SGD calibrated classifier.

Quantity Ensemble Models

Parameter Default What it does
Use Qty LightGbm On Enable LightGbm quantity regressor.
Use Qty FastTree On Enable FastTree quantity regressor.
Use Qty FastForest On Enable FastForest quantity regressor.
Use Qty SDCA On Enable SDCA quantity regressor.
Use Qty FastTree Tweedie On Enable FastTree Tweedie quantity regressor.
Use Qty OGD On Enable Online Gradient Descent quantity regressor.
Use Qty LBFGS Poisson On Enable LBFGS Poisson quantity regressor.

Direction Feature Params

Parameter Default What it does
(Slope) Start Bars Ago 14 Start bar (ago) for VWAP slope.
(Slope) End Bars Ago 0 End bar (ago) for VWAP slope.
Delta source Bars Bars (default): volume delta and VWAP estimated from each bar - works on any history, fast backtests. Ticks: from tick data - exact, needs the tick history downloaded.
(Delta) Type Bid ask Cumulative delta calculation type.
(Delta) Period Session Cumulative delta period.
(Delta) Size Filter 0 Delta size filter (0 = off).
(VWAP) Resolution Tick The data the indicator will run off of: Standard Tick
(ATR) Period 14 ATR period for features.
(MACD) Fast 12 MACD fast period.
(MACD) Slow 26 MACD slow period.
(MACD) Smooth 9 MACD signal smoothing period.

ML Metrics Filter

Parameter Default What it does
Min AUC 0.0 Minimum AUC required to pass metrics filter.
Min F1 0.0 Minimum F1 score required to pass metrics filter.
Min Accuracy 0.0 Minimum accuracy required to pass metrics filter.
Min Precision 0.0 Minimum precision required to pass metrics filter.
Min Recall 0.0 Minimum recall required to pass metrics filter.
Min Qty R2 -1.0 Minimum quantity ensemble R2 required to use quantity forecast.
Max Qty MAE 1000000.0 Maximum quantity ensemble MAE allowed to use quantity forecast.

Panel Style

Parameter Default What it does
Panel position Top right Corner of the price panel where the ML panel is drawn.
Panel scale (%) 100 Size of the ML panel: 100 = normal, 50 = half, 200 = double.
Panel opacity 75 Opacity of the ML panel's background (0-100).

Probability Style

Parameter Default What it does
Probability font Consolas 11 Font family for probability labels (e.g. Arial, Consolas).
Probability color dodger blue Text color for probability labels on chart.
Probability offset (ticks) 0 Vertical offset in ticks: positive = above bar, negative = below.

Requirements

The order-flow features need NinjaTrader Order Flow+. For the Commitment of Traders features turn on Tools → Options → Market Data → Download COT data at startup.