mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-08-20 15:58:07 +00:00
refactor: Fixed initialization bug
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
//| Copyright 2025, xxxxxxxx|
|
//| Copyright 2025, xxxxxxxx|
|
||||||
//+------------------------------------------------------------------+
|
//+------------------------------------------------------------------+
|
||||||
#property copyright "Copyright 2025, xxxxxxxx"
|
#property copyright "Copyright 2025, xxxxxxxx"
|
||||||
#property version "3.00" // True Moving Linear Regression
|
#property version "3.10" // Fixed initialization bug
|
||||||
#property description "Professional Moving Linear Regression (Curve)."
|
#property description "Professional Moving Linear Regression (Curve)."
|
||||||
#property description "Plots the end-point of the regression line for every bar."
|
#property description "Plots the end-point of the regression line for every bar."
|
||||||
|
|
||||||
@@ -122,6 +122,14 @@ int OnCalculate(const int rates_total,
|
|||||||
if(CheckPointer(g_calculator) == POINTER_INVALID)
|
if(CheckPointer(g_calculator) == POINTER_INVALID)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
// CRITICAL FIX: Initialize buffers on full recalculation
|
||||||
|
if(prev_calculated == 0)
|
||||||
|
{
|
||||||
|
ArrayInitialize(BufferUpper, EMPTY_VALUE);
|
||||||
|
ArrayInitialize(BufferLower, EMPTY_VALUE);
|
||||||
|
ArrayInitialize(BufferMiddle, EMPTY_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
ENUM_APPLIED_PRICE price_type;
|
ENUM_APPLIED_PRICE price_type;
|
||||||
if(InpSourcePrice <= PRICE_HA_CLOSE)
|
if(InpSourcePrice <= PRICE_HA_CLOSE)
|
||||||
price_type = (ENUM_APPLIED_PRICE)(-(int)InpSourcePrice);
|
price_type = (ENUM_APPLIED_PRICE)(-(int)InpSourcePrice);
|
||||||
@@ -129,7 +137,6 @@ int OnCalculate(const int rates_total,
|
|||||||
price_type = (ENUM_APPLIED_PRICE)InpSourcePrice;
|
price_type = (ENUM_APPLIED_PRICE)InpSourcePrice;
|
||||||
|
|
||||||
//--- Delegate calculation with prev_calculated optimization
|
//--- Delegate calculation with prev_calculated optimization
|
||||||
//--- Using CalculateMoving for the continuous curve
|
|
||||||
g_calculator.CalculateMoving(rates_total, prev_calculated, open, high, low, close, price_type, BufferMiddle, BufferUpper, BufferLower);
|
g_calculator.CalculateMoving(rates_total, prev_calculated, open, high, low, close, price_type, BufferMiddle, BufferUpper, BufferLower);
|
||||||
|
|
||||||
return(rates_total);
|
return(rates_total);
|
||||||
|
|||||||
Reference in New Issue
Block a user