mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-21 03:58:04 +00:00
feat(tests): enhance tests with GBM for noise generation and improve tolerance for MAMA validation
feat(trends): implement IDisposable in Bessel and Conv classes to manage event subscriptions fix(trends): add validation for period and parameters in Kama and MGDI calculations fix(trends): clamp logarithmic calculations in JMA to avoid -Infinity
This commit is contained in:
@@ -103,6 +103,18 @@ public sealed class Tema : AbstractBase
|
||||
// We don't need the output, just the final state
|
||||
int len = source.Length;
|
||||
double lastValid = 0;
|
||||
|
||||
// Search for the first finite value to initialize lastValid
|
||||
// If no finite value is found, lastValid remains 0
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (double.IsFinite(source[i]))
|
||||
{
|
||||
lastValid = source[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
EmaState s1 = _state1;
|
||||
EmaState s2 = _state2;
|
||||
EmaState s3 = _state3;
|
||||
@@ -312,6 +324,16 @@ public sealed class Tema : AbstractBase
|
||||
double decay = 1.0 - alpha;
|
||||
double lastValid = 0;
|
||||
|
||||
// Search for the first finite value to initialize lastValid
|
||||
for (int i = 0; i < source.Length; i++)
|
||||
{
|
||||
if (double.IsFinite(source[i]))
|
||||
{
|
||||
lastValid = source[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// State for EMA1
|
||||
double ema1_val = 0;
|
||||
double ema1_e = 1.0;
|
||||
|
||||
Reference in New Issue
Block a user