Skip to content
All library documents

A Forex Expert Advisor Using Historical Bar Frequencies for Directional Probabilities

Article MQL5 code base

Summary

This MetaTrader 5 Expert Advisor estimates the likelihood of price rising or falling from historical bar patterns. It examines a configurable history, groups observations into clusters of bars, and counts how often closes move above or below opens by a specified pip threshold. The resulting frequencies are displayed on the chart as directional probabilities. With trading enabled, the EA can open a buy or sell when the corresponding probability passes a stated threshold of 51%.

Position size may be fixed or calculated from account balance and a chosen risk setting. Stop-loss and take-profit levels can also be set. The document supplies default parameter examples, including the historical lookback, pip threshold, and cluster size, but does not report tests, profitability, or calibration quality. It gives little detail about handling overlapping observations, changing market regimes, transaction costs, or the statistical uncertainty in estimated probabilities. The described probabilities therefore should not be treated as a demonstrated predictive edge.

Key ideas

  • The EA estimates directional probabilities by counting threshold-sized price moves across historical bar clusters.
  • It can display the probabilities and trade when either direction exceeds a 51% threshold.
  • Position sizing may use a fixed lot or a balance-based risk calculation, with optional stop-loss and take-profit levels.
  • The document provides no performance results or evidence that the probability estimates predict future prices.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.