The repo hosts Bag-of-SFA-Symbols classifier from scratch in pure MQL5, turning price windows into words and bags of words into a regime classifier. Benchmarked against Dynamic Time Warping on BTCUSD, the BOSS ensemble wins on clean accuracy and runs about twenty times faster.
Найти файл
Файлы репозитория (в начале последний коммит)
Имя файла Текст последнего коммита Дата последнего коммита
2026-08-14 00:09:39 +00:00
Include/BOSS initial commit 2026-07-13 16:04:52 +00:00
Indicators/BOSS initial commit 2026-07-13 16:05:21 +00:00
Scripts/BOSS initial commit 2026-07-13 16:05:51 +00:00
README.md Add README 2026-08-14 00:09:39 +00:00

BOSS

Bag-of-SFA-Symbols classifier written from scratch in pure MQL5. Turns price windows into words, and bags of words into a regime classifier.

Companion code for the MQL5 article: https://www.mql5.com/en/articles/23491

What it does

Symbolic Fourier Approximation converts a price window into a short string: the window goes through a Fourier transform, the low coefficients are kept, and each is binned into a letter. Similar shapes become the same word, and noise that does not change the shape drops out.

BOSS then counts words rather than comparing series point by point. That is what makes it fast, and it is why one classifier is not enough: a single window length sees one time scale, so the ensemble spans several.

Regimes are labelled without hand-labelling, which matters because hand-labels are where this kind of study usually goes wrong.

Benchmarked against Dynamic Time Warping on BTCUSD, the ensemble wins on clean accuracy and runs roughly twenty times faster. BOSSvsDTWBenchmark.mq5 reproduces that comparison, and BOSSNoiseSweep.mq5 is the noise robustness sweep.

Layout

Include/BOSS/SFA.mqh                  Symbolic Fourier Approximation
Include/BOSS/FourierTransform.mqh     the transform behind SFA
Include/BOSS/BOSS.mqh                 bag-of-words model and ensemble
Include/BOSS/RegimeLabeler.mqh        unsupervised regime labels
Indicators/BOSS/BOSSRegime.mq5        the regime indicator
Scripts/BOSS/BOSSSelfTest.mq5         correctness checks
Scripts/BOSS/BOSSvsDTWBenchmark.mq5   accuracy and speed against DTW
Scripts/BOSS/BOSSNoiseSweep.mq5       robustness under added noise

Run BOSSSelfTest.mq5 first. If it fails, nothing downstream is worth reading.

Disclaimer

Educational code. Past behaviour of any model or dataset says nothing about future results. Test on your own data and broker conditions before drawing conclusions.