SFA/README.md
2026-08-14 00:09:53 +00:00

43 lines
1.6 KiB
Markdown

# SFA
Symbolic Fourier Approximation in MQL5, and a direct comparison against SAX on
identical windows.
Companion code for the MQL5 article: https://www.mql5.com/en/articles/24006
## What it does
SAX spends its bits describing where a window sits in time. SFA spends them
describing its shape: the window goes through a Fourier transform, the low
coefficients are kept, and those are binned into letters.
The bins are not fixed. Multiple Coefficient Binning learns them from the data,
so each coefficient gets breakpoints matched to its own distribution rather than
to an assumed normal.
The lower bound is where this gets useful and where it is easy to get wrong.
SFA admits a distance bound that lets the search skip candidates safely, and the
article works through the factor of two that the bound carries, since getting it
wrong either breaks correctness or throws away the speed.
`SFACompare.mq5` runs SAX and SFA over the same windows so the comparison is
like for like rather than two tuned systems talking past each other.
## Layout
```
Include/SFA/SFATransform.mqh Fourier front end and MCB binning
Include/SFA/SFAAnalogs.mqh analog search with the lower bound
Include/SAX/SAXTransform.mqh SAX, included for the comparison
Indicators/SFA/SFAAnalog.mq5 the indicator
Scripts/SFA/SFAValidate.mq5 validation harness
Scripts/SFA/SFACompare.mq5 SAX against SFA on identical windows
```
Run `SFAValidate.mq5` first, then `SFACompare.mq5` on your own symbol.
## 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.