- MQL5 100%
| Имя файла | Текст последнего коммита | Дата последнего коммита |
|---|---|---|
| Experts/BOCPD | ||
| Include/BOCPD | ||
| Indicators/BOCPD | ||
| README.md | ||
BOCPD
Bayesian Online Change-Point Detection in MQL5. Maintains a probability distribution over how long the current regime has lasted, and updates it bar by bar, so a break is flagged as it happens rather than after a lookback window catches up.
Companion code for the MQL5 article: https://www.mql5.com/en/articles/23482
What it does
The run-length posterior is the whole method. At every bar the model asks how likely it is that the current regime started 1 bar ago, 2 bars ago, and so on. A break shows up as probability mass collapsing from a long run length onto zero. Nothing here is a threshold on a moving average.
CBOCPD in BOCPDModel.mqh carries the recursion. Three consumers sit on top
of it, which is the point of the article: the same signal is useful in more
than one place.
BOCPDRegime.mq5plots the break probability directly, as a monitor.BOCPDAdaptiveMA.mq5is a moving average that resets itself when the model says the regime changed, instead of dragging stale history across the break.BOCPDRiskOverlay.mq5uses it as a meta-layer over position sizing rather than as an entry signal.
Layout
Include/BOCPD/BOCPDModel.mqh the recursion, CBOCPD
Indicators/BOCPD/BOCPDRegime.mq5 break probability monitor
Indicators/BOCPD/BOCPDAdaptiveMA.mq5 self-resetting adaptive average
Experts/BOCPD/BOCPDRiskOverlay.mq5 risk meta-layer
Copy the folders into your terminal's MQL5 directory and compile.
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.