Skip to content
All library documents

Runs Bars: Thresholds, Calibration, and State Persistence

Article MQL5 articles

Summary

Runs bars close when the larger of the cumulative buy-side or sell-side metric crosses an adaptive threshold. Unlike imbalance bars, which net opposing flow, runs bars accumulate each side separately. This can keep bars forming during choppy periods when alternating trades cancel out in an imbalance measure, while both methods capture active directional markets. Tick, volume, and dollar variants use the same signed inputs as their imbalance counterparts but apply a different boundary rule.

The article describes Python calibration from median tick density and separate average buy- and sell-side contributions, with small floors for one-sided or synthetic samples. It also outlines MQL5 implementation, persistence of the dual accumulators and tick-rule state, and parity checks that report matching bar sequences on the same tick stream. The approach depends on representative initialization data; symmetric seeds simplify setup but may not reflect unequal side intensities. The document presents implementation guidance and behavioral comparisons, not broad empirical evidence that runs bars improve trading performance.

Key ideas

  • Runs bars accumulate positive and negative flow separately and close when the larger side crosses its threshold.
  • Imbalance bars net opposing flow, so alternating activity may suppress their accumulator while runs-bar accumulators continue to grow.
  • Tick, volume, and dollar runs bars differ in their input metric but share the same boundary logic.
  • Calibration estimates expected bar length and buy- and sell-side contributions separately.
  • Persistent state must include both accumulators and the tick-rule state to resume consistently after a restart.

Tags

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