chore: delete old Stochastic_Adaptive files

This commit is contained in:
Toh4iem9
2025-11-22 12:33:26 +01:00
parent 6f6e12520e
commit f2c8365d4b
4 changed files with 0 additions and 327 deletions
@@ -1,67 +0,0 @@
# Stochastic Adaptive Professional
## 1. Summary (Introduction)
The `Stochastic_Adaptive_Pro` is an implementation of Frank Key's innovative "Variable-Length Stochastic" concept, which was popularized by Perry Kaufman. It is an "intelligent" oscillator that solves a major drawback of the classic Stochastic: its tendency to get "stuck" in overbought or oversold zones during a strong, sustained trend.
This indicator achieves this by dynamically adjusting its own lookback period based on the market's "trendiness," which it measures using **Kaufman's Efficiency Ratio (ER)**.
* In a **strong, trending market**, the indicator automatically **lengthens its period**, becoming less sensitive and helping the trader to stay with the trend.
* In a **choppy, sideways market**, it automatically **shortens its period**, becoming more responsive to identify potential turning points at the edges of the range.
This dual-mode behavior makes it a powerful and versatile tool for both trend-following and range-bound strategies.
## 2. Mathematical Foundations and Calculation Logic
The calculation is a multi-stage process that combines Kaufman's ER with the classic Slow Stochastic formula.
### Required Components
* **ER Period (N):** The lookback period for the Efficiency Ratio.
* **Min/Max Stochastic Periods (MinP, MaxP):** The range within which the Stochastic period can vary.
* **Stochastic Smoothing Periods:** Slowing Period and %D Period.
### Calculation Steps (Algorithm)
1. **Calculate the Efficiency Ratio (ER):** First, the ER is calculated over period `N` to measure the market's signal-to-noise ratio. The result is a value between 0 (pure noise) and 1 (perfect trend).
* $\text{ER}_t = \frac{\text{Abs}(P_t - P_{t-N})}{\sum_{i=0}^{N-1} \text{Abs}(P_{t-i} - P_{t-i-1})}$
2. **Calculate the Adaptive Stochastic Period (NSP):** The ER is then used to calculate the new, dynamic lookback period for the Stochastic on each bar.
* $\text{NSP}_t = \text{Integer}[(\text{ER}_t \times (\text{MaxP} - \text{MinP})) + \text{MinP}]$
3. **Apply the Slow Stochastic Formula with the Adaptive Period:** The standard Slow Stochastic logic is applied, but the crucial difference is that the `Raw %K` is calculated using the dynamic `NSP` for each bar.
* **Calculate Raw %K (using NSP):**
$\text{Highest High} = \text{Highest Price over the last NSP}_t \text{ bars}$
$\text{Lowest Low} = \text{Lowest Price over the last NSP}_t \text{ bars}$
$\text{Raw \%K}_t = 100 \times \frac{P_t - \text{Lowest Low}}{\text{Highest High} - \text{Lowest Low}}$
* **Calculate Slow %K and %D:** The `Raw %K` is then smoothed using fixed-period moving averages to produce the final %K (main) and %D (signal) lines.
## 3. MQL5 Implementation Details
* **Modular Calculation Engine (`Stochastic_Adaptive_Calculator.mqh`):** All mathematical logic is encapsulated in a dedicated include file. The engine first calculates the ER and the adaptive period for the entire history, then calculates the Stochastic using these dynamic period values.
* **Reusable Components:** The engine leverages our universal `CalculateMA` helper function for the final %K and %D smoothing steps, ensuring consistency with our other Stochastic indicators.
* **Object-Oriented Design (Inheritance):** The standard `_HA` derived class architecture is used to seamlessly support calculations on Heikin Ashi price data.
* **Stability via Full Recalculation:** The indicator performs a full recalculation on every tick. This is the most robust approach for a complex, state-dependent indicator where the lookback period itself is constantly changing.
## 4. Parameters
* **ER Period (`InpErPeriod`):** The lookback period for the Efficiency Ratio calculation. Default is `10`.
* **Min Stochastic Period (`InpMinStochPeriod`):** The shortest possible period for the Stochastic, used in choppy markets. Default is `5`.
* **Max Stochastic Period (`InpMaxStochPeriod`):** The longest possible period for the Stochastic, used in strong trends. Default is `30`.
* **Slowing Period (`InpSlowingPeriod`):** The fixed period for the first smoothing of the Raw %K. Default is `3`.
* **%D Period (`InpDPeriod`):** The fixed period for smoothing the main %K line to create the signal line. Default is `3`.
* **Applied Price (`InpSourcePrice`):** The source price for the calculation.
* **%D MA Type (`InpDMAType`):** The type of moving average for the %D signal line.
## 5. Usage and Interpretation
The key to using this indicator is understanding its dual nature.
* **In Strong Trends:** When the market is moving decisively in one direction, the indicator's period will lengthen. It will stay away from the extreme overbought/oversold zones for longer than a standard Stochastic. This is a feature, not a bug. It helps you **stay in a winning trade** and avoid exiting prematurely on minor pullbacks. Do not look for reversal signals from the extremes during these phases.
* **In Sideways/Ranging Markets:** When the market is choppy, the indicator's period will shorten. Its behavior will become very similar to a fast standard Stochastic. In this mode, it is excellent for identifying potential turning points near the top (>80) and bottom (<20) of the range.
* **Crossovers:** The crossover of the %K and %D lines provides standard bullish and bearish signals, but their reliability is enhanced by the adaptive context. A bullish crossover after the indicator has been in a "slow mode" (trending) and pulls back can be a very powerful trend-continuation signal.
@@ -1,92 +0,0 @@
//+------------------------------------------------------------------+
//| Stochastic_Adaptive_Pro.mq5 |
//| Copyright 2025, xxxxxxxx|
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, xxxxxxxx"
#property version "1.00"
#property description "Frank Key's Variable-Length Stochastic, using Kaufman's ER."
#property description "Dynamically adjusts its period based on market trendiness."
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots 2
#property indicator_level1 20.0
#property indicator_level2 50.0
#property indicator_level3 80.0
#property indicator_minimum 0.0
#property indicator_maximum 100.0
#property indicator_label1 "%K"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrDodgerBlue
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
#property indicator_label2 "%D"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrCoral
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
#include <MyIncludes\Stochastic_Adaptive_Calculator.mqh>
//--- Input Parameters ---
input group "Adaptive Settings"
input int InpErPeriod = 10; // Efficiency Ratio Period
input int InpMinStochPeriod= 5; // Minimum Stochastic Period
input int InpMaxStochPeriod= 30; // Maximum Stochastic Period
input group "Stochastic & Price Settings"
input int InpSlowingPeriod = 3;
input int InpDPeriod = 3;
input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD;
input ENUM_MA_TYPE InpDMAType = SMA;
//--- Indicator Buffers ---
double BufferK[], BufferD[];
//--- Global calculator object ---
CStochasticAdaptiveCalculator *g_calculator;
//+------------------------------------------------------------------+
int OnInit()
{
SetIndexBuffer(0, BufferK, INDICATOR_DATA);
SetIndexBuffer(1, BufferD, INDICATOR_DATA);
ArraySetAsSeries(BufferK, false);
ArraySetAsSeries(BufferD, false);
if(InpSourcePrice <= PRICE_HA_CLOSE)
g_calculator = new CStochasticAdaptiveCalculator_HA();
else
g_calculator = new CStochasticAdaptiveCalculator();
if(CheckPointer(g_calculator) == POINTER_INVALID ||
!g_calculator.Init(InpErPeriod, InpMinStochPeriod, InpMaxStochPeriod, InpSlowingPeriod, InpDPeriod, InpDMAType))
{
Print("Failed to create or initialize Adaptive Stochastic Calculator.");
return(INIT_FAILED);
}
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("Stoch Adaptive%s(%d,%d-%d)", (InpSourcePrice <= PRICE_HA_CLOSE ? " HA" : ""), InpErPeriod, InpMinStochPeriod, InpMaxStochPeriod));
IndicatorSetInteger(INDICATOR_DIGITS, 2);
int draw_begin = InpErPeriod + InpMaxStochPeriod + InpSlowingPeriod + InpDPeriod;
PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, draw_begin);
PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, draw_begin);
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 = (InpSourcePrice <= PRICE_HA_CLOSE) ? (ENUM_APPLIED_PRICE)(-(int)InpSourcePrice) : (ENUM_APPLIED_PRICE)InpSourcePrice;
g_calculator.Calculate(rates_total, open, high, low, close, price_type, BufferK, BufferD);
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
@@ -1,75 +0,0 @@
# Stochastic Adaptive RSI Professional
## 1. Summary (Introduction)
The `Stochastic_Adaptive_RSI_Pro` is a highly advanced, experimental oscillator that combines two powerful adaptive concepts into a single indicator. It takes the logic of the **Stochastic RSI** and merges it with the **variable-length period** mechanism from Frank Key's Adaptive Stochastic.
The result is a "doubly adaptive" oscillator that measures where the RSI is relative to its own highs and lows over a **dynamically changing lookback period**. The period itself adapts to the market's trendiness, which is measured by Kaufman's Efficiency Ratio (ER).
* In a **strong, trending market**, the indicator's lookback period on the RSI lengthens, aiming to reduce premature signals.
* In a **choppy, sideways market**, the period shortens, aiming to increase sensitivity to turns within the range.
This indicator explores the concept of applying adaptive techniques to an already smoothed data series (the RSI), resulting in a unique, hybrid momentum profile.
## 2. Mathematical Foundations and Calculation Logic
The calculation is a complex, four-stage sequential process.
### Required Components
* **RSI Period (N_rsi):** The lookback period for the base RSI.
* **ER Period (N_er):** The lookback period for the Efficiency Ratio.
* **Min/Max Stochastic Periods (MinP, MaxP):** The range for the adaptive period.
* **Stochastic Smoothing Periods:** Slowing Period and %D Period.
### Calculation Steps (Algorithm)
1. **Calculate the Base RSI:** First, a standard Wilder's RSI is calculated on the source price over the period `N_rsi`. This creates the primary data series for the oscillator.
2. **Calculate the Efficiency Ratio (ER):** Separately, the ER is calculated on the **source price** over the period `N_er` to measure the market's trendiness.
* $\text{ER}_t = \frac{\text{Abs}(P_t - P_{t-N_{er}})}{\sum_{i=0}^{N_{er}-1} \text{Abs}(P_{t-i} - P_{t-i-1})}$
3. **Calculate the Adaptive Stochastic Period (NSP):** The ER is used to calculate the new, dynamic lookback period for the Stochastic on each bar.
* $\text{NSP}_t = \text{Integer}[(\text{ER}_t \times (\text{MaxP} - \text{MinP})) + \text{MinP}]$
4. **Apply the Slow Stochastic Formula to the RSI with the Adaptive Period:** The standard Slow Stochastic logic is applied to the **RSI series**, but the `Raw %K` is calculated using the dynamic `NSP` for each bar.
* **Calculate Raw %K (using NSP on RSI):**
$\text{Highest High} = \text{Highest value of RSI over the last NSP}_t \text{ bars}$
$\text{Lowest Low} = \text{Lowest value of RSI over the last NSP}_t \text{ bars}$
$\text{Raw \%K}_t = 100 \times \frac{\text{RSI}_t - \text{Lowest Low}}{\text{Highest High} - \text{Lowest Low}}$
* **Calculate Slow %K and %D:** The `Raw %K` is then smoothed using fixed-period moving averages.
## 3. MQL5 Implementation Details
* **Modular and Composite Design:** The `Stochastic_Adaptive_RSI_Calculator.mqh` uses a composition-based design. It **contains an instance** of our robust `CRSIProCalculator` to generate the base RSI data, and it reuses the ER calculation logic from our KAMA implementation.
* **Reusable Components:** The calculator leverages our universal `CalculateMA` helper function for the final %K and %D smoothing steps.
* **Object-Oriented Design (Inheritance):** The standard `_HA` derived class architecture is used to seamlessly support calculations on Heikin Ashi price data.
## 4. Parameters
* **RSI Period (`InpRSIPeriod`):** The lookback period for the base RSI calculation.
* **ER Period (`InpErPeriod`):** The lookback period for the Efficiency Ratio calculation.
* **Min Stochastic Period (`InpMinStochPeriod`):** The shortest possible period for the Stochastic on the RSI.
* **Max Stochastic Period (`InpMaxStochPeriod`):** The longest possible period for the Stochastic on the RSI.
* **Slowing/D Periods:** The fixed periods for the final smoothing steps.
* **Applied Price (`InpSourcePrice`):** The source price for the calculation.
* **%D MA Type (`InpDMAType`):** The type of moving average for the %D signal line.
## 5. Usage and Interpretation
The Stochastic Adaptive RSI is a hybrid oscillator with a unique character. Its behavior is a blend of the `Stochastic RSI` and the `Stochastic Adaptive` indicators.
* **Comparison to its "Parents":**
* It is **smoother** than the standard `Stochastic Adaptive` (which is based on raw price) because its input is the already-smoothed RSI line.
* It is **more responsive and "jagged"** than the standard `Stochastic RSI` (which uses a fixed period) because its lookback period is constantly changing.
* **Interpreting the Behavior:** This indicator attempts to find a middle ground. It aims to provide the "trend-following" benefit of the adaptive period while working on a less noisy data series (RSI). However, this "double processing" (smoothing from RSI + adaptive period) can sometimes lead to a "hyper-refined" signal that may lose some of the raw power of its simpler counterparts.
* **Strategy:** It should be used like other Stochastic oscillators, looking for:
* **Overbought (>80) and Oversold (<20)** conditions.
* **Crossovers** of the %K and %D lines for entry/exit signals.
* **Divergences** with price.
It is best used by traders who find the standard `Stochastic RSI` too slow but the standard `Stochastic Adaptive` too noisy for their particular strategy or timeframe.
@@ -1,93 +0,0 @@
//+------------------------------------------------------------------+
//| Stochastic_Adaptive_RSI_Pro.mq5 |
//| Copyright 2025, xxxxxxxx|
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, xxxxxxxx"
#property version "1.00"
#property description "Variable-Length Stochastic applied to an RSI series."
#property description "Dynamically adjusts its period based on market trendiness (ER)."
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots 2
#property indicator_level1 20.0
#property indicator_level2 50.0
#property indicator_level3 80.0
#property indicator_minimum 0.0
#property indicator_maximum 100.0
#property indicator_label1 "%K"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrDodgerBlue
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
#property indicator_label2 "%D"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrCoral
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
#include <MyIncludes\Stochastic_Adaptive_RSI_Calculator.mqh>
//--- Input Parameters ---
input group "Adaptive Settings"
input int InpRSIPeriod = 14; // RSI Period
input int InpErPeriod = 10; // Efficiency Ratio Period
input int InpMinStochPeriod= 5; // Minimum Stochastic Period on RSI
input int InpMaxStochPeriod= 30; // Maximum Stochastic Period on RSI
input group "Stochastic & Price Settings"
input int InpSlowingPeriod = 3;
input int InpDPeriod = 3;
input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD;
input ENUM_MA_METHOD InpDMAType = MODE_SMA;
//--- Indicator Buffers ---
double BufferK[], BufferD[];
//--- Global calculator object ---
CStochasticAdaptiveRSICalculator *g_calculator;
//+------------------------------------------------------------------+
int OnInit()
{
SetIndexBuffer(0, BufferK, INDICATOR_DATA);
SetIndexBuffer(1, BufferD, INDICATOR_DATA);
ArraySetAsSeries(BufferK, false);
ArraySetAsSeries(BufferD, false);
if(InpSourcePrice <= PRICE_HA_CLOSE)
g_calculator = new CStochasticAdaptiveRSICalculator_HA();
else
g_calculator = new CStochasticAdaptiveRSICalculator();
if(CheckPointer(g_calculator) == POINTER_INVALID ||
!g_calculator.Init(InpRSIPeriod, InpErPeriod, InpMinStochPeriod, InpMaxStochPeriod, InpSlowingPeriod, InpDPeriod, InpDMAType))
{
Print("Failed to create or initialize Adaptive StochRSI Calculator.");
return(INIT_FAILED);
}
IndicatorSetString(INDICATOR_SHORTNAME, StringFormat("Stoch Adaptive RSI%s", (InpSourcePrice <= PRICE_HA_CLOSE ? " HA" : "")));
IndicatorSetInteger(INDICATOR_DIGITS, 2);
int draw_begin = InpRSIPeriod + InpErPeriod + InpMaxStochPeriod + InpSlowingPeriod + InpDPeriod;
PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, draw_begin);
PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, draw_begin);
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 = (InpSourcePrice <= PRICE_HA_CLOSE) ? (ENUM_APPLIED_PRICE)(-(int)InpSourcePrice) : (ENUM_APPLIED_PRICE)InpSourcePrice;
g_calculator.Calculate(rates_total, open, high, low, close, price_type, BufferK, BufferD);
return(rates_total);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+