mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-08-02 23:27:43 +00:00
refactor(indicators): Added Adaptive Source Selection
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| RSI_Adaptive_Pro.mq5 |
|
||||
//| Copyright 2025, xxxxxxxx|
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2025, xxxxxxxx"
|
||||
#property version "1.00"
|
||||
#property version "2.00" // Added Adaptive Source Selection
|
||||
#property description "Adaptive RSI with a variable period based on market volatility."
|
||||
|
||||
#property indicator_separate_window
|
||||
@@ -30,6 +29,9 @@ input group "Adaptive RSI Settings"
|
||||
input int InpPivotalPeriod = 14; // The central RSI period
|
||||
input int InpVolaShort = 5; // Short period for volatility measurement
|
||||
input int InpVolaLong = 10; // Long period for volatility averaging
|
||||
// NEW: Adaptive Source
|
||||
input ENUM_ADAPTIVE_SOURCE_RSI InpAdaptiveSource= ADAPTIVE_SOURCE_RSI_STANDARD;
|
||||
|
||||
input group "Price Source"
|
||||
input ENUM_APPLIED_PRICE_HA_ALL InpSourcePrice = PRICE_CLOSE_STD;
|
||||
|
||||
@@ -51,7 +53,7 @@ int OnInit()
|
||||
g_calculator = new CAdaptiveRSICalculator();
|
||||
|
||||
if(CheckPointer(g_calculator) == POINTER_INVALID ||
|
||||
!g_calculator.Init(InpPivotalPeriod, InpVolaShort, InpVolaLong))
|
||||
!g_calculator.Init(InpPivotalPeriod, InpVolaShort, InpVolaLong, InpAdaptiveSource))
|
||||
{
|
||||
Print("Failed to create or initialize Adaptive RSI Calculator.");
|
||||
return(INIT_FAILED);
|
||||
@@ -68,12 +70,12 @@ int OnInit()
|
||||
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&[])
|
||||
int OnCalculate(const int rates_total, const int prev_calculated, 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, BufferRSI);
|
||||
g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, BufferRSI);
|
||||
return(rates_total);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user