mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-07-27 20:47:44 +00:00
refactor: Fixed initialization bug (Vertical Lines)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
//| Copyright 2025, xxxxxxxx|
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2025, xxxxxxxx"
|
||||
#property version "1.00"
|
||||
#property version "1.10" // Fixed initialization bug (Vertical Lines)
|
||||
#property description "Professional Linear Regression Channel (Straight Segment)"
|
||||
#property description "Draws the regression channel for the most recent N bars."
|
||||
|
||||
@@ -104,6 +104,15 @@ int OnCalculate(const int rates_total,
|
||||
if(CheckPointer(g_calculator) == POINTER_INVALID)
|
||||
return 0;
|
||||
|
||||
// CRITICAL FIX: Initialize buffers on full recalculation (e.g. timeframe switch)
|
||||
// This prevents "ghost" 0.0 values which cause vertical lines.
|
||||
if(prev_calculated == 0)
|
||||
{
|
||||
ArrayInitialize(BufferUpper, EMPTY_VALUE);
|
||||
ArrayInitialize(BufferLower, EMPTY_VALUE);
|
||||
ArrayInitialize(BufferMiddle, EMPTY_VALUE);
|
||||
}
|
||||
|
||||
ENUM_APPLIED_PRICE price_type = (InpSourcePrice <= PRICE_HA_CLOSE) ? (ENUM_APPLIED_PRICE)(-(int)InpSourcePrice) : (ENUM_APPLIED_PRICE)InpSourcePrice;
|
||||
|
||||
// Clear the buffer index just before the channel starts to create the visual "cut"
|
||||
|
||||
Reference in New Issue
Block a user