Skip to content
All library documents

PAC Oscillator: Counting Bars Since Price Crossed a Moving Average

Article MQL5 code base

Summary

PAC, or Periods After Crossing MA, is an oscillator that tracks the number of bars since price most recently crossed a moving average. Its histogram is positive after an upward crossing and negative after a downward crossing. While price remains on the same side of the average, the value increments or decrements by one each bar; when price is on the opposite side from the prior bar, the count resets to positive or negative one according to the current side.

The indicator has configurable moving-average period, calculation method, and applied price. The document gives a default example using a 14-period simple moving average of closing prices. It describes the calculation and color convention but provides no trading rules, test results, or evidence that the count predicts returns. PAC therefore serves as a descriptive measure of crossing recency and direction, whose usefulness would need separate evaluation for any trading application.

Key ideas

  • PAC counts bars elapsed since price crossed a moving average.
  • The count grows positively while price stays above the average and negatively while it stays below.
  • A change in the price-average relationship resets the value to positive or negative one.
  • Users can configure the average period, calculation method, and applied price.
  • The document gives no trading performance evidence or standalone entry and exit rules.

Tags

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