Discussing the article: "Price Action Analysis Toolkit Development (Part 41): Building a Statistical Price-Level EA in MQL5"

 

Check out the new article: Price Action Analysis Toolkit Development (Part 41): Building a Statistical Price-Level EA in MQL5.

Statistics has always been at the heart of financial analysis. By definition, statistics is the discipline that collects, analyzes, interprets, and presents data in meaningful ways. Now imagine applying that same framework to candlesticks—compressing raw price action into measurable insights. How helpful would it be to know, for a specific period of time, the central tendency, spread, and distribution of market behavior? In this article, we introduce exactly that approach, showing how statistical methods can transform candlestick data into clear, actionable signals.

In this article we show how those metrics translate into practical, chart-friendly signals: they become horizontal reference lines (mean, median, P25/P75, modal levels), inputs to ATR-scaled thresholds that distinguish breakouts from reversals, and the basis for a z-score signal engine that flags unusually extreme price action. Crucially, the implementation we present (the KDE Level Sentinel EA) emphasizes reproducibility and usability: snapshots freeze reference levels for forward monitoring, labels are kept stable and non-overlapping, and signals are drawn as precise chart arrows that mark the exact triggering price.

Read on to learn the math behind each metric, the implementation details in MQL5, and how to interpret the EA’s outputs so you can move from raw candlesticks to clear, testable trading hypotheses.

Like I mentioned, we are trying to implement statistical methods to price action, so we are using typical price for all statistical calculations. Typical Price (TP) is calculated by adding a bar’s high, low, and close and dividing the sum by three; it balances the trading range with the closing level, smoothing isolated spikes and producing a steadier series than the close alone. By incorporating intra-bar extremes without requiring the open, TP provides richer inputs for distributional statistics—mean, median, and kernel density estimates—improving stability and signal quality for downstream models. Compared with alternatives such as Close, HL/2, or OHLC4, TP strikes a pragmatic middle ground: it captures both range and direction in a compact, robust input ideal for price-action statistical analysis.

Below are the statistical metrics we derive from the typical price (TP). Each metric highlights a different aspect of how price behaves over time—from central tendency and dispersion to frequency and structure. 

Author: Christian Benjamin