mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-08-20 07:48:06 +00:00
refactor(indicators): Optimized for incremental calculation
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Polynomial_Regression_Slope_Pro.mq5 |
|
||||
//| Copyright 2025, xxxxxxxx|
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2025, xxxxxxxx"
|
||||
#property version "1.00"
|
||||
#property version "2.00" // Optimized for incremental calculation
|
||||
#property description "Calculates the slope (1st derivative) of a moving Polynomial Regression."
|
||||
#property description "Functions as a smooth, zero-lag momentum oscillator."
|
||||
|
||||
@@ -60,12 +59,14 @@ 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, price_type, open, high, low, close, BufferSlope);
|
||||
|
||||
g_calculator.Calculate(rates_total, prev_calculated, price_type, open, high, low, close, BufferSlope);
|
||||
|
||||
return(rates_total);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user