Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

Metatrader 5 Indicator | Trend BOSS | MQL5 Release

Fresh MQL5 code release – perfect for enhancing your MT4/MT5 strategies.

Image for Trend BOSS

Overview


Installation and File Structure

The headers are included as <BOSS\...> and the indicator lives in an Indicators\BOSS subfolder, so the layout below has to be preserved.

File
Description
Indicators\BOSS\BOSSRegime.mq5
The indicator. Trains a BOSS ensemble on recent history at load time and colour-codes the regime lane.
Include\BOSS\FourierTransform.mqh
CDFT: real-input Fourier front end over ALGLIB's FFT, returning the low coefficients for SFA.
Include\BOSS\SFA.mqh
CMCB and CSFA: learned equi-depth binning per coefficient slot, and window to word.
Include\BOSS\BOSS.mqh
CBossHistogram, CBossTransform, CBossClassifier and CBossEnsemble: the bag, the BOSS distance, and the voting ensemble.
Include\BOSS\RegimeLabeler.mqh
CRegimeLabeler: rule-based trend / range / volatile labels from autocorrelation and volatility.

Recover from drawdowns intelligently with the Auto Recovery Expert Advisor for MT4/MT5. Perfect for hedging strategies. Learn more.


Input Parameters

Parameter
Default
What it does
Segment
120
Bars per classified segment. BOSS represents a series by the distribution of words its sliding window produces, so the segment has to be long enough to yield many words.
WordLen
2
Fourier coefficients kept, each contributing two letters. The measured robust operating point; raising it overfits noise.
Alphabet
4
Letters available per coefficient slot. Allowed range is 2 to 10.
TrainBars
2000
History bars used to train the ensemble, taken from closed bars only. Fewer bars means faster loading and a narrower sample of regimes.
TrendACF
0.05
Lag-1 autocorrelation above which the labeler calls a training segment trending. Lowered from the class default of 0.15 to balance the training classes, since a strict threshold leaves too few trend examples to learn from.
VolHighMult
1.3
Volatility above this multiple of the mean segment volatility marks a training segment volatile. Relative, not absolute, so it adapts to the instrument.
ShowLabel
true
Draw a text label naming the current regime in the chart corner.
Note: the two labeler thresholds shape the training data, not the live classification. They decide what the ensemble is taught to call a trend or a volatile stretch, so changing them changes what the lane means. Print the training summary in the Experts log after loading to see how many segments of each class the labeler produced; a class with very few examples will be classified poorly no matter how good the ensemble is.


Research Basis

The implementation follows the two papers that define the method:

  • Patrick Schäfer, The BOSS is concerned with time series classification in the presence of noise, Data Mining and Knowledge Discovery, 2015. The bag-of-words representation, the BOSS distance, and the ensemble with its 92% retention rule.
  • Patrick Schäfer and Mikael Högqvist, SFA: A Symbolic Fourier Approximation and Index for Similarity Search in High Dimensional Datasets, EDBT 2012. Symbolic Fourier Approximation and Multiple Coefficient Binning.

One point is worth stating plainly. The labels the ensemble learns from are generated by a simple statistical rule rather than by hand, so the indicator learns to reproduce that rule from window shape alone. It is a transparent, mechanical definition of regime, not an oracle, and a richer or forward-looking labeler would give BOSS a cleaner target. The engine is built so that swapping the labeler is a small change.

A companion article builds every layer from scratch, explains the mathematics, and runs the full benchmark against Dynamic Time Warping: Bag-of-SFA-Symbols (BOSS) in MQL5: Symbolic Time-Series Classification for Market Regimes.

Level up your trading with professional RobotFX expert advisors and indicators. Visit robotfx.org for proven MT4/MT5 tools.

75666

Best MetaTrader Indicators + Profitable Expert Advisors