From 00576a4862bfa32e4a61c58acd12e19df5d19b9b Mon Sep 17 00:00:00 2001 From: Toh4iem9 Date: Fri, 2 Jan 2026 13:44:05 +0100 Subject: [PATCH] docs(indicators): Wrapper using CMO_Engine + MA Engine --- Indicators/MyIndicators/CMO_Pro.md | 54 +++++++++++++++++------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/Indicators/MyIndicators/CMO_Pro.md b/Indicators/MyIndicators/CMO_Pro.md index 3bd3c75..83dc012 100644 --- a/Indicators/MyIndicators/CMO_Pro.md +++ b/Indicators/MyIndicators/CMO_Pro.md @@ -4,13 +4,11 @@ The Chande Momentum Oscillator (CMO), developed by Tushar Chande, is a pure momentum indicator that measures the direction and strength of a trend. Unlike other oscillators like the RSI which can become "compressed" at their extremes, the CMO uses a distinct calculation that allows it to oscillate freely between -100 and +100. -It works by calculating the sum of all positive price changes and the sum of all negative price changes over a given period, and then expressing the difference as a percentage of the total movement. +Our `CMO_Pro` implementation is a comprehensive, professional version that significantly enhances the classic indicator. It includes: -* Values approaching **+100** indicate strong bullish momentum and potentially overbought conditions. -* Values approaching **-100** indicate strong bearish momentum and potentially oversold conditions. -* The **zero line** represents a point of equilibrium where bullish and bearish pressures are balanced. - -Our `CMO_Pro` implementation is a professional, standalone version that allows the calculation to be based on either **standard** or **Heikin Ashi** price data. +* A fully customizable **Signal Line** for crossover strategies. +* Optional **Bollinger Bands** applied directly to the CMO, providing dynamic overbought/oversold levels based on momentum volatility. +* Support for both **standard** and **Heikin Ashi** price data. ## 2. Mathematical Foundations and Calculation Logic @@ -31,40 +29,50 @@ The CMO's formula is direct and intuitive, focusing solely on the net momentum o 2. **Calculate the CMO Value:** The final CMO value is calculated using the following formula, which normalizes the result to the -100 to +100 range. $\text{CMO}_i = 100 \times \frac{\text{Sum Up}_i - \text{Sum Down}_i}{\text{Sum Up}_i + \text{Sum Down}_i}$ +3. **Calculate Signal Line:** A moving average of the CMO line is calculated. + +4. **Calculate Bollinger Bands:** Standard Bollinger Bands are calculated on the CMO line, centered around the Signal Line. + ## 3. MQL5 Implementation Details Our MQL5 implementation is built on our standard, robust, and object-oriented framework. * **Modular Calculator Engine (`CMO_Calculator.mqh`):** - All core calculation logic is encapsulated within a dedicated and reusable include file. This engine was efficiently created by refactoring the validated CMO logic from our `VIDYA_Calculator`, ensuring consistency and code reusability across the indicator suite. + All core calculation logic is encapsulated within a dedicated and reusable include file. + * **Composition:** The calculator internally uses our universal `MovingAverage_Engine.mqh` to handle the smoothing of the Signal Line. This allows for advanced smoothing types (like DEMA or TEMA) beyond the standard SMA. + +* **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_calculated` to process only new bars. + * **Persistent Buffers:** Internal buffers persist their state between ticks. + * **Robust Offset Handling:** The engine correctly handles the initialization periods of the chained calculations. * **Object-Oriented Design (Inheritance):** * A base class, `CCMOCalculator`, performs the full CMO calculation on a given source price. - * A derived class, `CCMOCalculator_HA`, inherits all the logic and only overrides the `PreparePriceSeries` method to supply Heikin Ashi data as the input. This clean polymorphic approach eliminates code duplication. - -* **Simplified Main Indicator (`CMO_Pro.mq5`):** - The main `.mq5` file is a clean "wrapper" that handles user inputs, creates the appropriate calculator object (`standard` or `_HA`), and delegates the entire calculation with a single function call in `OnCalculate()`. - -* **Stability via Full Recalculation:** The indicator performs a full recalculation on every tick. For a straightforward, non-recursive indicator like CMO, this ensures maximum stability and simplicity in the code. + * A derived class, `CCMOCalculator_HA`, inherits all the logic and only overrides the `PreparePriceSeries` method to supply Heikin Ashi data as the input. ## 4. Parameters (`CMO_Pro.mq5`) -* **CMO Period (`InpPeriodCMO`):** The lookback period for summing up and down price movements. A common value is `14`, but shorter periods (like `9`) will result in a more sensitive oscillator. -* **Applied Price (`InpSourcePrice`):** The source price for the calculation. This unified dropdown menu allows you to select from all standard and Heikin Ashi price types. +* **CMO Period (`InpPeriodCMO`):** The lookback period for summing up and down price movements. (Default: `14`). +* **Applied Price (`InpSourcePrice`):** The source price for the calculation. (Standard or Heikin Ashi). +* **Overlay Settings:** + * **Display Mode (`InpDisplayMode`):** Toggles between `CMO_Only`, `CMO_and_MA`, and `CMO_and_Bands`. + * **MA Period (`InpPeriodMA`):** The period for the signal line. + * **MA Method (`InpMethodMA`):** The type of moving average for the signal line. Supports: **SMA, EMA, SMMA, LWMA, TMA, DEMA, TEMA**. + * **Bands Deviation (`InpBandsDev`):** The standard deviation multiplier for the Bollinger Bands. ## 5. Usage and Interpretation The CMO is a versatile tool for identifying momentum, overbought/oversold conditions, and potential trend reversals. * **Overbought/Oversold Levels:** - * **CMO > +50:** The market is considered overbought, and bullish momentum may be overextended. This can be an early warning of a potential bearish reversal or consolidation. - * **CMO < -50:** The market is considered oversold, and bearish momentum may be exhausted. This can signal a potential bullish reversal or bounce. + * **CMO > +50:** The market is considered overbought. + * **CMO < -50:** The market is considered oversold. + * **Bollinger Bands:** When the CMO touches or exceeds its own Bollinger Bands, it signals an extreme statistical deviation in momentum, often preceding a reversal. * **Zero Line Crossover:** - * A crossover **above the zero line** indicates that bullish momentum is now stronger than bearish momentum, confirming an uptrend. - * A crossover **below the zero line** indicates that bearish momentum has taken control, confirming a downtrend. - * The zero line can act as a filter; for example, only taking long trades when CMO is above 0. + * A crossover **above the zero line** indicates that bullish momentum is now stronger than bearish momentum. + * A crossover **below the zero line** indicates that bearish momentum has taken control. -* **Divergence:** - * **Bearish Divergence:** Occurs when the price makes a new high, but the CMO fails to make a new high. This suggests that the momentum behind the uptrend is weakening and a reversal may be near. - * **Bullish Divergence:** Occurs when the price makes a new low, but the CMO makes a higher low. This indicates that bearish momentum is fading and a bottom may be forming. +* **Signal Line Crossover:** + * A crossover of the CMO line and its Signal Line provides earlier entry/exit signals than the zero line cross.