mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-08-05 00:27:44 +00:00
chore: delete old files
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
# Windowed MA Professional
|
||||
|
||||
## 1. Summary (Introduction)
|
||||
|
||||
The Windowed MA Pro is an indicator based on John Ehlers' research into advanced **Finite Impulse Response (FIR) filters**. It serves as a superior alternative to the Simple Moving Average (SMA) by employing "windowing" functions to create a smoother, more responsive output.
|
||||
|
||||
A standard SMA uses a "rectangular window," giving equal weight to all prices in the lookback period, which results in poor filtering characteristics. This indicator allows the user to apply mathematically superior weighting schemes:
|
||||
|
||||
1. **Triangular Window:** A simple weighting that gives the most emphasis to the middle of the lookback period.
|
||||
2. **Hann Window:** A more advanced, cosine-based weighting function that provides excellent smoothing and is Ehlers' recommended choice for most trading applications.
|
||||
|
||||
The result is a high-fidelity moving average that produces a cleaner representation of the trend with less noise than a standard SMA.
|
||||
|
||||
## 2. Mathematical Foundations and Calculation Logic
|
||||
|
||||
The indicator is a weighted moving average, where the weights are determined by the selected windowing function.
|
||||
|
||||
### Calculation Steps (Algorithm)
|
||||
|
||||
For each bar, the indicator looks back over the last `N` periods.
|
||||
|
||||
1. **Calculate Weights:** For each position `j` within the `N`-period window, a specific weight is calculated based on the chosen `Window Type`.
|
||||
* **SMA:** `Weight = 1`
|
||||
* **Triangular:** The weight increases linearly to the midpoint of the window and then decreases.
|
||||
* **Hann:** The weight is calculated using a cosine formula, creating a smooth, bell-shaped curve: $W_j = 0.5 \times (1 - \cos(\frac{2\pi \times j}{N-1}))$
|
||||
2. **Calculate Weighted Sum:** The source price at each position is multiplied by its corresponding weight and summed up.
|
||||
3. **Normalize:** The final indicator value is the weighted sum divided by the sum of all weights.
|
||||
|
||||
## 3. MQL5 Implementation Details
|
||||
|
||||
* **Unified Calculator (`Windowed_MA_Calculator.mqh`):** The calculation for all window types is handled by a single, flexible calculator class. The user's choice determines which weighting formula is used inside the calculation loop.
|
||||
* **Heikin Ashi Integration:** The indicator fully supports calculation on smoothed Heikin Ashi data.
|
||||
* **FIR-based Logic:** This is a non-recursive (FIR) filter. Its calculation at any given bar depends only on the last `N` prices.
|
||||
* **Stability via Full Recalculation:** The indicator employs a full recalculation on every `OnCalculate` call.
|
||||
|
||||
## 4. Parameters
|
||||
|
||||
* **Window Type (`InpWindowType`):** Allows the user to select the weighting function: `SMA`, `Triangular`, or `Hann`. **`Hann` is recommended for the best smoothing.**
|
||||
* **Period (`InpPeriod`):** The lookback period (`N`) for the moving average.
|
||||
* **Applied Price (`InpSourcePrice`):** The source price for the calculation (e.g., Close, Open, etc.).
|
||||
* **Candle Source (`InpCandleSource`):** Selects between `Standard` and `Heikin Ashi` candles.
|
||||
|
||||
## 5. Usage and Interpretation
|
||||
|
||||
The Windowed MA should be used as a high-quality replacement for a standard Simple Moving Average.
|
||||
|
||||
* **Trend Identification:** Use it to identify the direction of the trend. Price trading above the line indicates an uptrend; price below indicates a downtrend.
|
||||
* **Dynamic Support and Resistance:** The line acts as a dynamic S/R level. Due to its superior smoothing, it often provides more reliable support/resistance than a standard SMA.
|
||||
* **Crossover Systems:** A two-line crossover system using a fast and a slow Windowed MA (especially with the Hann window) will produce smoother and potentially cleaner signals than a standard SMA crossover system.
|
||||
|
||||
### **Combined Strategy with Windowed Momentum (Advanced)**
|
||||
|
||||
The true power of the Ehlers windowing concept is revealed when using the `Windowed_MA_Pro` and `Windowed_Momentum_Pro` indicators together. A key relationship exists between them:
|
||||
|
||||
* **The Momentum Oscillator's zero-cross predicts the Moving Average's turning point.**
|
||||
* When the `Windowed_Momentum` oscillator crosses **above its zero line**, it signals that the `Windowed_MA` is forming a **trough (a bottom)**.
|
||||
* When the `Windowed_Momentum` oscillator crosses **below its zero line**, it signals that the `Windowed_MA` is forming a **peak (a top)**.
|
||||
|
||||
This relationship can be used to anticipate changes in the short-term trend defined by the moving average, providing a powerful leading signal.
|
||||
@@ -1,87 +0,0 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Windowed_MA_Pro.mq5 |
|
||||
//| Copyright 2025, xxxxxxxx|
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2025, xxxxxxxx"
|
||||
#property version "1.10" // Refactored to be a dedicated on-chart smoother
|
||||
#property description "FIR filters with selectable Windowing functions (SMA, Triangular, Hann) applied to price."
|
||||
|
||||
#property indicator_chart_window
|
||||
#property indicator_buffers 1
|
||||
#property indicator_plots 1
|
||||
#property indicator_label1 "Windowed MA"
|
||||
#property indicator_type1 DRAW_LINE
|
||||
#property indicator_color1 clrAqua
|
||||
#property indicator_style1 STYLE_SOLID
|
||||
#property indicator_width1 1
|
||||
|
||||
#include <MyIncludes\Windowed_MA_Calculator.mqh>
|
||||
|
||||
enum ENUM_CANDLE_SOURCE { SOURCE_STD, SOURCE_HA };
|
||||
|
||||
//--- Input Parameters ---
|
||||
input ENUM_WINDOW_TYPE InpWindowType = W_HANN; // Windowing function type
|
||||
input int InpPeriod = 20; // Averaging Period
|
||||
input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD; // Price type for calculation
|
||||
input ENUM_CANDLE_SOURCE InpCandleSource= SOURCE_STD; // Candle type
|
||||
|
||||
//--- Indicator Buffers ---
|
||||
double BufferOutput[];
|
||||
|
||||
//--- Global calculator object ---
|
||||
CWindowedMACalculator *g_calculator;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit()
|
||||
{
|
||||
SetIndexBuffer(0, BufferOutput, INDICATOR_DATA);
|
||||
ArraySetAsSeries(BufferOutput, false);
|
||||
|
||||
if(InpCandleSource == SOURCE_HA)
|
||||
{
|
||||
g_calculator = new CWindowedMACalculator_HA();
|
||||
}
|
||||
else
|
||||
{
|
||||
g_calculator = new CWindowedMACalculator();
|
||||
}
|
||||
|
||||
// Initialize the calculator in PRICE mode
|
||||
if(CheckPointer(g_calculator) == POINTER_INVALID || !g_calculator.Init(InpPeriod, InpWindowType, SOURCE_PRICE))
|
||||
{
|
||||
Print("Failed to initialize Windowed MA Calculator.");
|
||||
return(INIT_FAILED);
|
||||
}
|
||||
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("W-MA(%d)", InpPeriod));
|
||||
PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, InpPeriod - 1);
|
||||
IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
|
||||
|
||||
return(INIT_SUCCEEDED);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
if(CheckPointer(g_calculator) != POINTER_INVALID)
|
||||
delete g_calculator;
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
int OnCalculate(const int rates_total, const int, const datetime&[], const double &open[], const double &high[], const double &low[], const double &close[], const long&[], const long&[], const int&[])
|
||||
{
|
||||
if(CheckPointer(g_calculator) == POINTER_INVALID)
|
||||
return 0;
|
||||
|
||||
ENUM_APPLIED_PRICE price_type;
|
||||
if(InpCandleSource == SOURCE_HA)
|
||||
price_type = (ENUM_APPLIED_PRICE)(-(int)InpSourcePrice);
|
||||
else
|
||||
price_type = (ENUM_APPLIED_PRICE)InpSourcePrice;
|
||||
|
||||
g_calculator.Calculate(rates_total, price_type, open, high, low, close, BufferOutput);
|
||||
return(rates_total);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -1,53 +0,0 @@
|
||||
# Windowed Momentum Professional
|
||||
|
||||
## 1. Summary (Introduction)
|
||||
|
||||
The Windowed Momentum Pro is an oscillator developed from the concepts in John Ehlers' "Windowing" article. Instead of applying the advanced FIR filters to the price, this indicator applies them to a **momentum source (Close - Open)**.
|
||||
|
||||
The indicator calculates a weighted average of the bar-by-bar momentum over a given period, using a selectable **windowing function** (SMA, Triangular, or Hann).
|
||||
|
||||
The result is a smooth, zero-mean oscillator that measures the underlying strength and direction of momentum. The use of the **Hann window** is particularly effective, as it creates a much cleaner and less noisy oscillator than a simple momentum calculation.
|
||||
|
||||
## 2. Mathematical Foundations and Calculation Logic
|
||||
|
||||
The indicator is a weighted moving average of the `Close - Open` value of each bar.
|
||||
|
||||
### Calculation Steps (Algorithm)
|
||||
|
||||
1. **Calculate Momentum Source:** For each bar, the source data is calculated as `Momentum = Close - Open`.
|
||||
2. **Apply Windowing Function:** A weighted moving average is calculated on this `Momentum` data series using the selected windowing function (SMA, Triangular, or Hann) over the `N`-period lookback window. The calculation is identical to the `Windowed MA Pro` indicator, but applied to a different data source.
|
||||
|
||||
## 3. MQL5 Implementation Details
|
||||
|
||||
* **Unified Calculator (`Windowed_MA_Calculator.mqh`):** This indicator uses the exact same, powerful calculator engine as the `Windowed_MA_Pro`. The only difference is that it is initialized in `SOURCE_MOMENTUM` mode.
|
||||
* **Heikin Ashi Integration:** The indicator fully supports calculation on smoothed Heikin Ashi data (`HA Close - HA Open`).
|
||||
* **FIR-based Logic:** This is a non-recursive (FIR) filter.
|
||||
* **Stability via Full Recalculation:** The indicator employs a full recalculation on every `OnCalculate` call.
|
||||
|
||||
## 4. Parameters
|
||||
|
||||
* **Window Type (`InpWindowType`):** Allows the user to select the weighting function: `SMA`, `Triangular`, or `Hann`. **`Hann` is recommended for the smoothest output.**
|
||||
* **Period (`InpPeriod`):** The lookback period (`N`) for the momentum averaging.
|
||||
* **Candle Source (`InpCandleSource`):** Selects between `Standard` and `Heikin Ashi` candles.
|
||||
|
||||
## 5. Usage and Interpretation
|
||||
|
||||
The Windowed Momentum is a classic zero-mean oscillator used for identifying momentum shifts and potential reversals.
|
||||
|
||||
* **Zero-Line Crossover:**
|
||||
* A cross **above the zero line** indicates that bullish momentum is taking control.
|
||||
* A cross **below the zero line** indicates that bearish momentum is dominant.
|
||||
* **Divergence:** This is one of the most powerful ways to use the indicator.
|
||||
* **Bullish Divergence:** Price makes a **new lower low**, but the Windowed Momentum makes a **higher low**. This signals weakening sell pressure and a potential bottom.
|
||||
* **Bearish Divergence:** Price makes a **new higher high**, but the Windowed Momentum makes a **lower high**. This signals weakening buy pressure and a potential top.
|
||||
* **Combined with Windowed MA:** Use the `Windowed_MA_Pro` to define the main trend. Then, use the `Windowed_Momentum_Pro` to time entries. In an uptrend (price > W-MA), look for the W-Momentum to form a valley (ideally below zero) and turn up as a high-probability entry signal.
|
||||
|
||||
### **Combined Strategy with Windowed MA (Primary Use)**
|
||||
|
||||
This oscillator is designed to be used in conjunction with its companion indicator, the `Windowed_MA_Pro`. The relationship between the two provides a powerful timing signal.
|
||||
|
||||
* **The Zero-Cross Predicts the MA's Turning Point:** The most important signal is the crossing of the zero line, as it directly corresponds to the turning points of the `Windowed_MA`.
|
||||
* **Buy Signal:** When the `Windowed_Momentum` line crosses **above the zero line**, it signals that the `Windowed_MA` on the main chart is forming a **trough (a bottom)**. This is a signal that the downtrend momentum has ended and an uptrend is beginning.
|
||||
* **Sell Signal:** When the `Windowed_Momentum` line crosses **below the zero line**, it signals that the `Windowed_MA` is forming a **peak (a top)**. This indicates the end of uptrend momentum.
|
||||
|
||||
This strategy allows a trader to use the Momentum oscillator as a **leading indicator** to anticipate the turning points of the smoother, lagging `Windowed_MA`.
|
||||
@@ -1,87 +0,0 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Windowed_Momentum_Pro.mq5 |
|
||||
//| Copyright 2025, xxxxxxxx|
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2025, xxxxxxxx"
|
||||
#property version "1.00"
|
||||
#property description "Ehlers' Windowed FIR filter applied to Momentum (Close-Open)."
|
||||
|
||||
#property indicator_separate_window // THIS IS THE KEY CHANGE
|
||||
#property indicator_buffers 1
|
||||
#property indicator_plots 1
|
||||
#property indicator_label1 "W-Momentum"
|
||||
#property indicator_type1 DRAW_LINE
|
||||
#property indicator_color1 clrAqua
|
||||
#property indicator_style1 STYLE_SOLID
|
||||
#property indicator_width1 1
|
||||
|
||||
#property indicator_level1 0.0
|
||||
#property indicator_levelstyle STYLE_SOLID
|
||||
#property indicator_levelcolor clrGray
|
||||
|
||||
#include <MyIncludes\Windowed_MA_Calculator.mqh>
|
||||
|
||||
enum ENUM_CANDLE_SOURCE { SOURCE_STD, SOURCE_HA };
|
||||
|
||||
//--- Input Parameters ---
|
||||
input ENUM_WINDOW_TYPE InpWindowType = W_HANN; // Windowing function type
|
||||
input int InpPeriod = 20; // Averaging Period
|
||||
// Note: Source Price is not needed as this indicator always uses Momentum (C-O)
|
||||
input ENUM_CANDLE_SOURCE InpCandleSource= SOURCE_STD; // Candle type
|
||||
|
||||
//--- Indicator Buffers ---
|
||||
double BufferOutput[];
|
||||
|
||||
//--- Global calculator object ---
|
||||
CWindowedMACalculator *g_calculator;
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
int OnInit()
|
||||
{
|
||||
SetIndexBuffer(0, BufferOutput, INDICATOR_DATA);
|
||||
ArraySetAsSeries(BufferOutput, false);
|
||||
|
||||
if(InpCandleSource == SOURCE_HA)
|
||||
{
|
||||
g_calculator = new CWindowedMACalculator_HA();
|
||||
}
|
||||
else
|
||||
{
|
||||
g_calculator = new CWindowedMACalculator();
|
||||
}
|
||||
|
||||
// Initialize the calculator in MOMENTUM mode
|
||||
if(CheckPointer(g_calculator) == POINTER_INVALID || !g_calculator.Init(InpPeriod, InpWindowType, SOURCE_MOMENTUM))
|
||||
{
|
||||
Print("Failed to initialize Windowed Momentum Calculator.");
|
||||
return(INIT_FAILED);
|
||||
}
|
||||
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("W-Mom(%d)", InpPeriod));
|
||||
PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, InpPeriod - 1);
|
||||
IndicatorSetInteger(INDICATOR_DIGITS, 4);
|
||||
|
||||
return(INIT_SUCCEEDED);
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
if(CheckPointer(g_calculator) != POINTER_INVALID)
|
||||
delete g_calculator;
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
int OnCalculate(const int rates_total, const int, const datetime&[], const double &open[], const double &high[], const double &low[], const double &close[], const long&[], const long&[], const int&[])
|
||||
{
|
||||
if(CheckPointer(g_calculator) == POINTER_INVALID)
|
||||
return 0;
|
||||
|
||||
// The price_type parameter is not used by the calculator in SOURCE_MOMENTUM mode,
|
||||
// but we pass a default value for consistency.
|
||||
g_calculator.Calculate(rates_total, PRICE_CLOSE, open, high, low, close, BufferOutput);
|
||||
return(rates_total);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//+------------------------------------------------------------------+
|
||||
Reference in New Issue
Block a user