mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-08-07 01:27:45 +00:00
refactor: Optimized for incremental calculation
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
# RSI Pro Indicator Family (Pro, %B, Width, Oscillator)
|
||||
# RSI Pro Indicator Family (Pro, %B, Oscillator)
|
||||
|
||||
## 1. Summary (Introduction)
|
||||
|
||||
This document covers our comprehensive, professionally coded MQL5 implementation of an advanced Relative Strength Index (RSI) indicator family. Moving beyond the classic RSI, this suite transforms the well-known momentum oscillator into a complete, multi-faceted analysis system for measuring the **dynamics of momentum itself**.
|
||||
|
||||
The core of the family is the **`RSI_Pro`** indicator, which integrates a fully customizable signal line and optional Bollinger Bands directly onto the RSI values. From this powerful base, we derive three specialized oscillators:
|
||||
The core of the family is the **`RSI_Pro`** indicator, which integrates a fully customizable signal line and optional Bollinger Bands directly onto the RSI values. From this powerful base, we derive two specialized oscillators:
|
||||
|
||||
* **`RSI_PercentB`**: Normalizes the RSI's position relative to its own volatility bands.
|
||||
* **`RSI_Band_Width_Pro`**: Measures the volatility of momentum, identifying "momentum squeezes".
|
||||
* **`RSI_Oscillator`**: Displays the difference between the RSI and its signal line as a histogram.
|
||||
|
||||
All indicators in this family are built on a shared, modular calculation engine and offer a seamless choice between standard price data and smoothed **Heikin Ashi** data, providing a powerful toolkit for advanced momentum analysis.
|
||||
@@ -38,8 +37,6 @@ All indicators in this family are derived from the same core components: the RSI
|
||||
$\text{Oscillator}_t = \text{RSI}_t - \text{Signal Line}_t$
|
||||
* **`RSI_PercentB`**: Normalizes the RSI's position relative to its bands.
|
||||
$\%B_t = \frac{\text{RSI}_t - \text{Lower Band}_t}{\text{Upper Band}_t - \text{Lower Band}_t}$
|
||||
* **`RSI_Band_Width`**: Measures the normalized width of the RSI's bands.
|
||||
$\text{BandWidth}_t = \frac{\text{Upper Band}_t - \text{Lower Band}_t}{\text{Signal Line}_t}$
|
||||
|
||||
## 3. MQL5 Implementation Details
|
||||
|
||||
@@ -49,11 +46,14 @@ Our MQL5 suite is built on a single, shared, modular, and robust calculation eng
|
||||
* An elegant, object-oriented inheritance model (`CRSIProCalculator` and `CRSIProCalculator_HA`) allows all indicators in the family to dynamically choose the correct calculation engine at runtime based on user input.
|
||||
* This **DRY (Don't Repeat Yourself)** approach ensures that any future improvements to the core logic are automatically inherited by all indicators in the family.
|
||||
|
||||
* **Stability via Full Recalculation:** All indicators employ a "brute-force" **full recalculation** on every tick. This is our core principle to ensure perfect accuracy and prevent any risk of calculation errors or visual glitches.
|
||||
* **Optimized Incremental Calculation:**
|
||||
All indicators employ an intelligent incremental algorithm.
|
||||
* They utilize the `prev_calculated` state to determine the exact starting point for updates.
|
||||
* **Persistent State:** The internal buffers (like `m_rsi_buffer`) persist their state between ticks. This allows recursive smoothing methods (like EMA and SMMA for the signal line) to continue seamlessly from the last known value without re-processing the entire history.
|
||||
* This results in **O(1) complexity** per tick, ensuring instant updates and zero lag, even on charts with extensive history.
|
||||
|
||||
* **Flexible "Pro" Indicators:** Functionality is consolidated into powerful "Pro" versions.
|
||||
* **`RSI_Pro.mq5`**: The main indicator, featuring a custom `enum` to seamlessly switch between standard and a full range of Heikin Ashi price types. It also has a `Display Mode` to show the RSI alone, with its signal line, or with the full Bollinger Bands.
|
||||
* **`RSI_Band_Width_Pro.mq5`**: This advanced oscillator includes selectable analysis modes: **Bands on BandWidth** (for dynamic momentum Squeeze detection) and **Extremes Channel** (for historical momentum Squeeze/Bulge levels).
|
||||
|
||||
## 4. Parameters
|
||||
|
||||
@@ -61,7 +61,7 @@ Our MQL5 suite is built on a single, shared, modular, and robust calculation eng
|
||||
* **Source Price (`InpSourcePrice`):** A comprehensive list of price sources, including all standard prices and a full range of Heikin Ashi prices.
|
||||
* **MA Period & Method:** The period and type of moving average for the signal line and/or Bollinger Bands centerline.
|
||||
* **Bands Deviation:** The standard deviation multiplier for the Bollinger Bands on the RSI.
|
||||
* **Display Mode:** (For `RSI_Pro` and `RSI_Band_Width_Pro`) Controls which components are visible on the chart.
|
||||
* **Display Mode:** (For `RSI_Pro`) Controls which components are visible on the chart.
|
||||
|
||||
## 5. Usage and Interpretation
|
||||
|
||||
@@ -79,8 +79,3 @@ This indicator family allows for a multi-layered analysis of market momentum.
|
||||
* **`RSI_PercentB` (The Normalized View):**
|
||||
* This oscillator normalizes the RSI's position into a 0-1 scale. It provides an objective measure of overbought/oversold conditions based on the momentum's own volatility.
|
||||
* Values above 1.0 or below 0.0 are clear signals of extreme momentum that may precede a reversal or consolidation.
|
||||
|
||||
* **`RSI_Band_Width_Pro` (The Momentum Volatility Meter):**
|
||||
* This is the most advanced tool in the family. It measures the **volatility of momentum**.
|
||||
* A **"Momentum Squeeze"** (low Band Width values, identified by the "Extremes Channel" or "Bands on BandWidth" modes) signals that momentum is consolidating. This often precedes a powerful breakout in price, as pent-up momentum is released.
|
||||
* A **"Momentum Bulge"** (high Band Width values) signals that momentum is at a historical extreme and may be unsustainable, often preceding a trend exhaustion.
|
||||
|
||||
Reference in New Issue
Block a user