46 lines
1.9 KiB
Markdown
46 lines
1.9 KiB
Markdown
# 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.
|