volume indicators

This commit is contained in:
Miha Kralj
2026-01-30 12:47:25 -08:00
parent 76d2b50cbb
commit 7b3a6520d2
99 changed files with 9539 additions and 283 deletions
+23 -2
View File
@@ -22,11 +22,13 @@ namespace QuanTAlib;
/// https://school.stockcharts.com/doku.php?id=technical_indicators:price_oscillators_ppo
/// </remarks>
[SkipLocalsInit]
public sealed class Apo : ITValuePublisher
public sealed class Apo : ITValuePublisher, IDisposable
{
private readonly Ema _emaFast;
private readonly Ema _emaSlow;
private readonly TValuePublishedHandler _handler;
private ITValuePublisher? _source;
private bool _disposed;
/// <summary>
/// Display name for the indicator.
@@ -87,7 +89,8 @@ public sealed class Apo : ITValuePublisher
/// <param name="slowPeriod">Slow EMA period (default 26)</param>
public Apo(ITValuePublisher source, int fastPeriod = 12, int slowPeriod = 26) : this(fastPeriod, slowPeriod)
{
source.Pub += _handler;
_source = source;
_source.Pub += _handler;
}
/// <summary>
@@ -194,4 +197,22 @@ public sealed class Apo : ITValuePublisher
SimdExtensions.Subtract(fastEma, slowEma, output);
}
/// <summary>
/// Disposes resources and unsubscribes from the source publisher.
/// </summary>
public void Dispose()
{
if (_disposed)
{
return;
}
_disposed = true;
if (_source != null)
{
_source.Pub -= _handler;
_source = null;
}
}
}