mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-22 12:38:06 +00:00
feat: update Qodana configuration to disable failure conditions and improve build stability
refactor: enhance Bilateral and SMA indicators to handle edge cases and improve state management refactor: clean up whitespace and formatting in various test files for consistency
This commit is contained in:
@@ -168,11 +168,21 @@ public sealed class Bilateral : AbstractBase
|
||||
_state.SumSq = currentSumSq;
|
||||
|
||||
double val = GetValidValue(input.Value);
|
||||
double oldNewest = _buffer.Newest; // Get current newest before overwriting
|
||||
_buffer.UpdateNewest(val);
|
||||
|
||||
_state.SumSq -= (oldNewest * oldNewest);
|
||||
_state.SumSq += (val * val);
|
||||
// Defensive check: if buffer is empty, treat as first value
|
||||
if (_buffer.Count == 0)
|
||||
{
|
||||
_buffer.Add(val);
|
||||
_state.SumSq += (val * val);
|
||||
}
|
||||
else
|
||||
{
|
||||
double oldNewest = _buffer.Newest; // Get current newest before overwriting
|
||||
_buffer.UpdateNewest(val);
|
||||
|
||||
_state.SumSq -= (oldNewest * oldNewest);
|
||||
_state.SumSq += (val * val);
|
||||
}
|
||||
}
|
||||
|
||||
double result = CalculateBilateral();
|
||||
|
||||
Reference in New Issue
Block a user