mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-14 08:38:04 +00:00
Fixes
This commit is contained in:
@@ -22,7 +22,7 @@ namespace QuanTAlib;
|
||||
public class Dsma : AbstractBase
|
||||
{
|
||||
private readonly CircularBuffer _buffer;
|
||||
private readonly double _c1, _c2, _c3;
|
||||
private readonly double _c2, _c3;
|
||||
private readonly double _scaleFactor;
|
||||
private readonly double _periodRecip; // 1/_period
|
||||
private readonly double _scaleByPeriod; // 5/_period
|
||||
@@ -59,7 +59,7 @@ public class Dsma : AbstractBase
|
||||
|
||||
_c2 = b1;
|
||||
_c3 = -a1 * a1;
|
||||
_c1 = 1.0 - _c2 - _c3;
|
||||
double _c1 = 1.0 - _c2 - _c3;
|
||||
_c1Half = _c1 * 0.5;
|
||||
_scaleByPeriod = 5.0 / period;
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ public sealed class Cv : AbstractBase
|
||||
private readonly double _omega;
|
||||
private double _prevClose;
|
||||
private double _prevVariance;
|
||||
private double _longTermVariance;
|
||||
private bool _isInitialized;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -82,7 +81,6 @@ public sealed class Cv : AbstractBase
|
||||
base.Init();
|
||||
_prevClose = 0;
|
||||
_prevVariance = 0;
|
||||
_longTermVariance = 0;
|
||||
_isInitialized = false;
|
||||
}
|
||||
|
||||
@@ -116,7 +114,7 @@ public sealed class Cv : AbstractBase
|
||||
// Initialize with first available data if not done
|
||||
if (!_isInitialized && _index > _period)
|
||||
{
|
||||
_longTermVariance = squaredReturn; // Use current squared return as initial estimate
|
||||
double _longTermVariance = squaredReturn; // Use current squared return as initial estimate
|
||||
_prevVariance = _longTermVariance;
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ namespace QuanTAlib;
|
||||
public sealed class Cvi : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private readonly int _smoothPeriod;
|
||||
private readonly CircularBuffer _smoothed;
|
||||
private readonly double _alpha;
|
||||
private double _ema;
|
||||
@@ -50,10 +49,9 @@ public sealed class Cvi : AbstractBase
|
||||
public Cvi(int period = 10, int smoothPeriod = 10)
|
||||
{
|
||||
_period = period;
|
||||
_smoothPeriod = smoothPeriod;
|
||||
_alpha = 2.0 / (_smoothPeriod + 1);
|
||||
WarmupPeriod = _period + _smoothPeriod;
|
||||
Name = $"CVI({_period},{_smoothPeriod})";
|
||||
_alpha = 2.0 / (smoothPeriod + 1);
|
||||
WarmupPeriod = _period + smoothPeriod;
|
||||
Name = $"CVI({_period},{smoothPeriod})";
|
||||
_smoothed = new CircularBuffer(_period);
|
||||
Init();
|
||||
}
|
||||
|
||||
+9
-13
@@ -42,7 +42,6 @@ namespace QuanTAlib;
|
||||
[SkipLocalsInit]
|
||||
public sealed class Fcb : AbstractBase
|
||||
{
|
||||
private readonly int _period;
|
||||
private readonly double _smoothing;
|
||||
private readonly CircularBuffer _highs;
|
||||
private readonly CircularBuffer _lows;
|
||||
@@ -56,11 +55,10 @@ public sealed class Fcb : AbstractBase
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Fcb(int period = 20, double smoothing = 0.5)
|
||||
{
|
||||
_period = period;
|
||||
_smoothing = smoothing;
|
||||
_alpha = 2.0 / (_period + 1);
|
||||
_alpha = 2.0 / (period + 1);
|
||||
WarmupPeriod = period + 4; // Need extra periods for fractal identification
|
||||
Name = $"FCB({_period},{_smoothing})";
|
||||
Name = $"FCB({period},{_smoothing})";
|
||||
_highs = new CircularBuffer(period);
|
||||
_lows = new CircularBuffer(period);
|
||||
Init();
|
||||
@@ -116,16 +114,14 @@ public sealed class Fcb : AbstractBase
|
||||
bool isFractalHigh = false;
|
||||
bool isFractalLow = false;
|
||||
|
||||
if (_index >= 5)
|
||||
{
|
||||
// Fractal high: current high is higher than 2 bars before and after
|
||||
isFractalHigh = _highs[2] > _highs[0] && _highs[2] > _highs[1] &&
|
||||
_highs[2] > _highs[3] && _highs[2] > _highs[4];
|
||||
// Fractal high: current high is higher than 2 bars before and after
|
||||
isFractalHigh = _highs[2] > _highs[0] && _highs[2] > _highs[1] &&
|
||||
_highs[2] > _highs[3] && _highs[2] > _highs[4];
|
||||
|
||||
// Fractal low: current low is lower than 2 bars before and after
|
||||
isFractalLow = _lows[2] < _lows[0] && _lows[2] < _lows[1] &&
|
||||
_lows[2] < _lows[3] && _lows[2] < _lows[4];
|
||||
|
||||
// Fractal low: current low is lower than 2 bars before and after
|
||||
isFractalLow = _lows[2] < _lows[0] && _lows[2] < _lows[1] &&
|
||||
_lows[2] < _lows[3] && _lows[2] < _lows[4];
|
||||
}
|
||||
|
||||
// Update EMAs with fractal points
|
||||
if (isFractalHigh)
|
||||
|
||||
Reference in New Issue
Block a user