feat: Add Prime method to various indicators for initializing state with historical data

- Implemented Prime method in Vel, Ao, Apo, Frama, Adl, Adosc, Aobv, Cmf, Efi, Eom, Iii, Kvo, Mfi, Nvi, Obv, Pvd, Pvi, Pvo, Pvr, Pvt, Tvi, Twap, Va, Vf, Vo, Vroc, Vwad, Vwap, and Vwma classes.
- The Prime method resets the indicator state and processes the provided historical bar data to initialize the indicator.
- Added warmup period property to Adl and Wad classes to define the minimum number of data points required for validity.
- Updated benchmark tests to use Batch methods for performance evaluation.
This commit is contained in:
Miha Kralj
2026-02-11 20:38:38 -08:00
parent 75c6a9f135
commit 653aafacd8
71 changed files with 10527 additions and 242 deletions
+30
View File
@@ -303,6 +303,18 @@ public sealed class Amat : ITValuePublisher, IDisposable
return Last;
}
/// <summary>
/// Updates the indicator with a bar value.
/// </summary>
/// <param name="bar">Input bar</param>
/// <param name="isNew">True if this is a new bar, False if it's an update to the last bar</param>
/// <returns>Updated trend value (+1, -1, or 0)</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TValue Update(TBar bar, bool isNew = true)
{
return Update(new TValue(bar.Time, bar.Close), isNew);
}
/// <summary>
/// Updates the indicator with a series of values.
/// </summary>
@@ -382,6 +394,24 @@ public sealed class Amat : ITValuePublisher, IDisposable
return result;
}
/// <summary>
/// Initializes the indicator state using the provided bar series history.
/// </summary>
/// <param name="source">Historical bar data.</param>
public void Prime(TBarSeries source)
{
Reset();
if (source.Count == 0)
{
return;
}
for (int i = 0; i < source.Count; i++)
{
Update(source[i], isNew: true);
}
}
/// <summary>
/// Calculates AMAT trend values for a span of input values.
/// </summary>