Skip to content
All library documents

Detecting Flat Trading Ranges for Breakout Stop Orders

Article MQL5 code base

Summary

This indicator looks for a flat price channel over a chosen period. It checks whether the highest and lowest closing prices remain within a specified range. When the condition is met, it uses the period’s high and low prices, adjusted by padding, to draw channel boundaries. An optional setting carries forward the previous bar’s channel boundaries when a channel was present.

The stated use is to identify levels for stop orders intended to catch a breakout from the range. The description gives the calculation logic but no performance results or detailed parameter guidance. It cautions that on larger timeframes, a very small distance between closing prices can prevent the indicator from finding a qualifying setup, so some charts may show no channel.

Key ideas

  • The indicator first checks whether closing prices fit within a specified range over the selected period.
  • When that condition holds, it draws boundaries from the period’s high and low prices with padding.
  • An optional setting considers the prior bar’s channel boundaries.
  • The channel is intended to help locate stop orders for a breakout from a flat range.
  • Small closing-price distances on larger timeframes may leave the indicator with no qualifying channel.

Tags

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