Back to list
DaveSkender

indicator-buffer

by DaveSkender

Stock Indicators for .NET is a C# NuGet package that transforms raw equity, commodity, forex, or cryptocurrency financial market price quotes into technical indicators and trading insights. You'll need this essential data in the investment tools that you're building for algorithmic trading, technical analysis, machine learning, or visual charting.

1,169🍴 265📅 Jan 22, 2026

SKILL.md


name: indicator-buffer description: Implement BufferList incremental indicators with efficient state management. Use for IIncrementFromChain or IIncrementFromQuote implementations. Covers interface selection, constructor patterns, and BufferListTestBase testing requirements.

BufferList indicator development

Interface selection

All BufferList implementations support IQuote inputs from the base class. The interface determines what additional input types are supported:

InterfaceAdditional InputsUse CaseExamples
IIncrementFromChainIReusable, (DateTime, double)Chainable single-value indicatorsSMA, EMA, RSI
IIncrementFromQuote(none - only IQuote)Requires OHLCV propertiesStoch, ATR, VWAP

Constructor pattern

public class MyIndicatorList : BufferList<MyResult>, IIncrementFromChain
{
    private readonly Queue<double> _buffer;

    // Primary constructor (parameters only)
    public MyIndicatorList(int lookbackPeriods)
    {
        ArgumentOutOfRangeException.ThrowIfLessThan(lookbackPeriods, 1);
        LookbackPeriods = lookbackPeriods;
        _buffer = new Queue<double>(lookbackPeriods);
    }

    // Chaining constructor (parameters + quotes)
    public MyIndicatorList(int lookbackPeriods, IReadOnlyList<IQuote> quotes)
        : this(lookbackPeriods) => Add(quotes);
}

Buffer management

Use extension methods from BufferListUtilities:

  • _buffer.Update(capacity, value) - Standard rolling buffer
  • _buffer.UpdateWithDequeue(capacity, value) - Returns dequeued value for sum adjustment

Note: Future refactor planned to rename BufferListUtilities to BufferListExtensions for .NET idiomatic naming.

State management

Use Clear() to reset all internal state:

public override void Clear()
{
    base.Clear();
    _buffer.Clear();
    _bufferSum = 0;
}

Testing constraints

  • Inherit BufferListTestBase (NOT TestBase)
  • Implement test interface matching increment interface:
    • IIncrementFromChainITestChainBufferList
    • IIncrementFromQuoteITestQuoteBufferList
  • Verify exact Series parity with bufferResults.IsExactly(seriesResults) (NOT Should().Be())
  • All 5 base class tests pass (incremental adds, batching, constructor chaining, Clear(), auto-pruning)

Required implementation

  • Source code: src/**/{IndicatorName}.BufferList.cs file exists
    • Inherits BufferList<TResult> and implements correct increment interface
    • Two constructors: primary + chaining via : this(...) => Add(quotes);
    • Uses BufferListUtilities.Update() or UpdateWithDequeue()
    • Clear() resets results and all internal buffers
  • Unit testing: tests/indicators/**/{IndicatorName}.BufferList.Tests.cs exists
    • Inherits BufferListTestBase and implements correct test interface
    • All 5 required tests from base class pass
    • Verifies equivalence with Series results

Anti-patterns to avoid

Manual buffer management (WRONG):

if (_buffer.Count == capacity) _buffer.Dequeue();
_buffer.Enqueue(value);

Use extension methods (CORRECT):

_buffer.Update(capacity, value);

Examples

  • Chain: src/e-k/Ema/Ema.BufferList.cs
  • Quote: src/s-z/Stoch/Stoch.BufferList.cs
  • Complex: src/a-d/Adx/Adx.BufferList.cs

See references/interface-selection.md for interface decision guidance.


Last updated: December 31, 2025

Score

Total Score

90/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 1000以上

+15
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

+5
Issue管理

オープンIssueが50未満

0/5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon