Skip to content
All library documents

Tick-Based Price Channels for Flexible Timeframes

Article MQL5 code base

Summary

The document describes a PriceChannel calculation that tracks the highest and lowest prices over a selected period. Its library updates on every tick, allowing channel calculations without relying on standard chart bars, including custom-duration bars and very short timeframes. The example compares the library with a conventional method that copies bar highs and lows, then accumulates the channel width during a test run.

The reported optimization run completed 200 passes in 2 minutes 57 seconds with the library, compared with 6 minutes 55 seconds for standard calculations. The author says the two methods produce identical tester results and that library performance depends little on the selected period. These timings are a single reported comparison, not a general benchmark. The document also notes a default convention using Bid for the channel high and Ask for the low, which users can configure; that quote-side choice may affect results. The article explains calculation mechanics rather than presenting a trading signal or evidence of profitability.

Key ideas

  • A PriceChannel measures the highest and lowest prices over a chosen period.
  • The library updates from ticks, so calculations need not be tied to standard bars.
  • The example reports faster optimization with the library than with the bar-based calculation.
  • The default high and low quote sides are Bid and Ask, respectively, and can be changed.

Tags

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