mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-20 03:28:05 +00:00
volume indicators
This commit is contained in:
@@ -190,7 +190,21 @@ public sealed class Atr : AbstractBase
|
||||
public override TSeries Update(TSeries source)
|
||||
{
|
||||
// Assumes source is already TR
|
||||
return _rma.Update(source);
|
||||
if (source.Count == 0)
|
||||
{
|
||||
return _rma.Update(source);
|
||||
}
|
||||
|
||||
var result = _rma.Update(source);
|
||||
|
||||
// Update instance state to match RMA state
|
||||
Last = _rma.Last;
|
||||
_isInitialized = true;
|
||||
|
||||
// Note: _prevBar cannot be updated from TSeries (no OHLC data)
|
||||
// but _isInitialized signals that subsequent TBar updates should work
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static TSeries CalculateTrueRange(TBarSeries source)
|
||||
|
||||
@@ -36,6 +36,9 @@ public sealed class Atrn : AbstractBase
|
||||
private State _state;
|
||||
private State _p_state;
|
||||
|
||||
private ITValuePublisher? _publisher;
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Creates ATRN with specified period.
|
||||
/// </summary>
|
||||
@@ -64,6 +67,7 @@ public sealed class Atrn : AbstractBase
|
||||
/// <param name="period">Period for ATR calculation</param>
|
||||
public Atrn(ITValuePublisher source, int period) : this(period)
|
||||
{
|
||||
_publisher = source;
|
||||
source.Pub += Handle;
|
||||
}
|
||||
|
||||
@@ -330,4 +334,19 @@ public sealed class Atrn : AbstractBase
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
if (disposing && _publisher != null)
|
||||
{
|
||||
_publisher.Pub -= Handle;
|
||||
_publisher = null;
|
||||
}
|
||||
_disposed = true;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user