5.6 KiB
Aroon Professional
1. Summary (Introduction)
The Aroon indicator, developed by Tushar Chande in 1995, is a technical analysis tool used to identify whether a security is trending and to measure the freshness or age of that trend. Unlike momentum oscillators that measure the magnitude of price changes, Aroon's core concept is based on time relative to price. It measures the number of periods that have passed since price recorded a new high or low within the lookback period.
The name "Aroon" is Sanskrit for "Dawn's Early Light," highlighting its purpose of detecting the beginning of new trends.
The system consists of two lines:
- Aroon Up: Measures the time since the last N-period high. A high value indicates a "fresh" uptrend.
- Aroon Down: Measures the time since the last N-period low. A high value indicates a "fresh" downtrend.
Our Aroon_Pro implementation is a unified, professional version that allows the calculation to be based on either standard or Heikin Ashi candles.
2. Mathematical Foundations and Calculation Logic
The Aroon calculation is a straightforward, non-recursive process based on finding the highest high and lowest low over a sliding window of time.
Required Components
- Aroon Period (N): The lookback period for the calculation (e.g., 25).
Calculation Steps (Algorithm)
For each bar, the indicator performs the following steps:
-
Identify the Lookback Window: Define the period of the last
Nbars, including the current bar. -
Find the Highest High: Within this window, find the bar with the absolute highest high price.
-
Count Bars Since High: Calculate the number of bars that have passed between the current bar and the bar where the highest high occurred. Let's call this
BarsSinceHigh. If the high is on the current bar, this value is 0. -
Calculate Aroon Up: Apply the Aroon formula:
\text{Aroon Up} = \frac{N - \text{BarsSinceHigh}}{N} \times 100 -
Find the Lowest Low: Within the same
N-bar window, find the bar with the absolute lowest low price. -
Count Bars Since Low: Calculate the number of bars that have passed since the lowest low occurred (
BarsSinceLow). -
Calculate Aroon Down: Apply the corresponding formula:
\text{Aroon Down} = \frac{N - \text{BarsSinceLow}}{N} \times 100
The "Sawtooth" Pattern Explained
The characteristic linearly declining, "sawtooth" appearance of the Aroon lines is a direct and intended result of its time-based formula. After a new high is made (BarsSinceHigh = 0, Aroon Up = 100), for every subsequent bar where a new high is not made, the BarsSinceHigh value increases by one, causing the Aroon Up value to decrease by a fixed amount (100 / N). This continues until a new high is formed within the period, at which point the line jumps back to 100.
3. MQL5 Implementation Details
Our MQL5 implementation follows a modern, object-oriented design pattern to ensure stability, reusability, and maintainability.
-
Modular Calculator Engine (
Aroon_Calculator.mqh): All core calculation logic is encapsulated within a reusable include file. This separates the mathematical complexity from the indicator's user interface and buffer management. -
Optimized Incremental Calculation (O(1)): Unlike basic implementations that recalculate the entire history on every tick, this indicator employs an intelligent incremental algorithm.
- State Tracking: It utilizes
prev_calculatedto process only new bars. - Persistent Buffers: Internal buffers persist their state between ticks, ensuring seamless updates without full recalculation.
- State Tracking: It utilizes
-
Object-Oriented Design (Inheritance):
- A base class,
CAroonCalculator, handles the entire shared calculation logic. - A derived class,
CAroonCalculator_HA, inherits from the base class and overrides only one specific function:PrepareSourceData. Its sole responsibility is to calculate and provide Heikin Ashi high/low data to the base class's calculation engine.
- A base class,
4. Parameters (Aroon_Pro.mq5)
- Aroon Period (
InpPeriodAroon): The lookback period (N) used for the calculation. The default value is25, as used in many platforms, but14is also a very common choice. - Candle Source (
InpCandleSource): Allows the user to select the candle type for finding highs and lows.CANDLE_STANDARD: Uses the standard chart's OHLC data.CANDLE_HEIKIN_ASHI: Uses smoothed Heikin Ashi data.
5. Usage and Interpretation
Aroon is used to answer the questions: "Is there a trend?" and "If so, how new is it?".
-
Trend Identification (Levels):
- Aroon Up > 70: Suggests a strong, fresh uptrend.
- Aroon Down > 70: Suggests a strong, fresh downtrend.
- Both lines below 30 (or 50): Suggests the market is consolidating or in a range, as no new highs or lows have been made recently.
-
Crossovers:
- When the Aroon Up line (green) crosses above the Aroon Down line (red), it signals potential bullish strength.
- When the Aroon Down line (red) crosses above the Aroon Up line (green), it signals potential bearish strength.
-
Extreme Readings (100):
- When Aroon Up hits 100, it confirms that a new high for the period was just made. This is a sign of strong bullish momentum.
- When Aroon Down hits 100, it confirms a new low for the period was just made, signaling strong bearish momentum.
-
Parallel Movement: When both lines move downwards in a relatively parallel fashion, it often indicates that the market is consolidating and the previous trend is aging. Traders often watch for a breakout following this pattern.