indicator-buffer
BufferList indicator development
Interface selection
| Interface | Additional Inputs | Use Case |
|---|---|---|
IIncrementFromChain |
IReusable, (DateTime, double) |
Chainable single-value indicators |
IIncrementFromQuote |
(none — only IQuote from base) | Requires OHLCV properties |
See references/interface-selection.md for decision tree.
Constructor pattern
The chaining constructor parameter type depends on the interface implemented:
// IIncrementFromChain — chaining ctor takes IReadOnlyList<IReusable>
public class EmaList : BufferList<EmaResult>, IIncrementFromChain, IEma
{
public EmaList(int lookbackPeriods)
{
Ema.Validate(lookbackPeriods);
LookbackPeriods = lookbackPeriods;
_buffer = new Queue<double>(lookbackPeriods);
}
public EmaList(int lookbackPeriods, IReadOnlyList<IReusable> values)
: this(lookbackPeriods) => Add(values);
}
// IIncrementFromQuote — chaining ctor takes IReadOnlyList<IQuote>
public class AdxList : BufferList<AdxResult>, IIncrementFromQuote, IAdx
{
public AdxList(int lookbackPeriods)
{
Adx.Validate(lookbackPeriods);
LookbackPeriods = lookbackPeriods;
}
public AdxList(int lookbackPeriods, IReadOnlyList<IQuote> quotes)
: this(lookbackPeriods) => Add(quotes);
}
Buffer management
_buffer.Update(capacity, value)— standard rolling buffer_buffer.UpdateWithDequeue(capacity, value)— returns dequeued value for sum adjustment
State management
Use Clear() to reset all internal state:
public override void Clear()
{
base.Clear();
_buffer.Clear();
_bufferSum = 0;
}
Testing constraints
- Inherit
BufferListTestBase IIncrementFromChain→ implementITestChainBufferListIIncrementFromQuote→ implementITestQuoteBufferList- Series parity:
bufferResults.IsExactly(seriesResults)
Required implementation
- Source code:
src/**/{IndicatorName}.BufferList.csfile exists- Inherits
BufferList<TResult>and implements correct increment interface - Two constructors: primary + chaining via
: this(...) => Add(...); - Uses
BufferListUtilities.Update()orUpdateWithDequeue() -
Clear()resets results and all internal buffers
- Inherits
- Unit testing:
tests/indicators/**/{IndicatorName}.BufferList.Tests.csexists- Inherits
BufferListTestBaseand implements correct test interface - All required abstract + interface methods implemented
- Verifies equivalence with Series results
- Inherits
- Catalog registration: Registered in
Catalog.Listings.cs - Performance benchmark: Add to
tools/performance/Perf.Buffer.cs - Public documentation: Update
docs/indicators/{IndicatorName}.md - Regression tests: Add to
tests/indicators/**/{IndicatorName}.Regression.Tests.cs - Migration guide: Update
docs/migration.mdfor notable and breaking changes from v2
More from daveskender/stock.indicators
indicator-catalog
Create and register indicator catalog entries for automation. Use for Catalog.cs files, CatalogListingBuilder patterns, parameter/result definitions, and PopulateCatalog registration.
17testing-standards
Testing conventions for Stock Indicators. Use for test naming (MethodName_StateUnderTest_ExpectedBehavior), FluentAssertions patterns, precision requirements, and test base class selection.
16performance-testing
Benchmark indicator performance with BenchmarkDotNet. Use for Series/Buffer/Stream benchmarks, regression detection, and optimization patterns. Target 1.5x Series for StreamHub, 1.2x for BufferList.
15code-completion
Quality gates checklist for completing code work before finishing implementation cycles
14indicator-series
Implement Series-style batch indicators with mathematical precision. Use for new StaticSeries implementations or optimization. Series results are the canonical reference—all other styles must match exactly. Focus on cross-cutting requirements and performance optimization decisions.
13indicator-stream
Implement StreamHub real-time indicators with O(1) performance. Use for ChainHub or QuoteProvider implementations. Covers provider selection, RollbackState patterns, performance anti-patterns, and comprehensive testing with StreamHubTestBase.
13