Indicator Buffer
Developmentindicator-bufferIndicator Buffer is an Agent Skill for development published in the facioquo/stock-indicators-dotnet repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Implement BufferList incremental indicators with efficient state management. Use for IIncrementFromChain or IIncrementFromBar implementations. Covers interface selection, constructor patterns, and BufferListTestBase testing requirements.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/facioquo/stock-indicators-dotnet/blob/HEAD/.agents/skills/indicator-buffer/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/indicator-buffer, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
BufferList indicator development
Interface selection
| Interface | Additional Inputs | Use Case |
|---|---|---|
IIncrementFromChain | IReusable, (DateTime, double) | Chainable single-value indicators |
IIncrementFromBar | (none — only IBar 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);
}
// IIncrementFromBar — chaining ctor takes IReadOnlyList<IBar>
public class AdxList : BufferList<AdxResult>, IIncrementFromBar, IAdx
{
public AdxList(int lookbackPeriods)
{
Adx.Validate(lookbackPeriods);
LookbackPeriods = lookbackPeriods;
}
public AdxList(int lookbackPeriods, IReadOnlyList<IBar> bars)
: this(lookbackPeriods) => Add(bars);
}
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→ implementITestChainBufferListIIncrementFromBar→ implementITestBarBufferList- Series parity:
bufferResults.IsExactly(seriesResults)
Required implementation
- Source code:
src/**/{IndicatorName}List.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/Library/Indicators/**/{IndicatorName}BufferListTests.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/Library/Indicators/**/{IndicatorName}RegressionTests.cs - Migration guide: Update
docs/migration/v3.mdfor notable and breaking changes from v2