Quantitative TA library (QuanTAlib) is a high-performance C# library for quantitative technical analysis, designed for Quantower and other C#-based trading platforms.
- Real-time streaming - Indicators calculate results from incoming data without re-processing history
- Update/correction support - Last value can be recalculated multiple times before advancing to next bar
- Valid from first bar - Mathematically correct results from the first value with
IsHotwarmup indicator - SIMD-optimized - Hardware-accelerated vector operations (AVX/SSE) for batch processing
- Zero-allocation hot paths - Minimal GC pressure for high-frequency scenarios
QuanTAlib uses a Structure of Arrays (SoA) memory layout optimized for numerical computing:
┌─────────────────────────────────────────────────────────────┐
│ Core Data Types │
├─────────────────────────────────────────────────────────────┤
│ TValue (16 bytes) │ Time-value pair (long + double) │
│ TBar (48 bytes) │ OHLCV bar (long + 5 doubles) │
│ TSeries │ Time series with SoA layout │
│ TBarSeries │ OHLCV series with SoA layout │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ Data Feeds │
├─────────────────────────────────────────────────────────────┤
│ IFeed │ Unified feed interface │
│ GBM │ Geometric Brownian Motion sim │
│ CsvFeed │ CSV file reader │
└─────────────────────────────────────────────────────────────┘
The SoA layout stores timestamps and values in separate contiguous arrays:
// TSeries internal structure
protected readonly List<long> _t; // Timestamps (contiguous)
protected readonly List<double> _v; // Values (contiguous)
// Direct SIMD access via Span<T>
ReadOnlySpan<double> values = series.Values;
double avg = values.AverageSIMD(); // Hardware-acceleratedThis enables:
- Cache locality - Sequential memory access patterns
- SIMD vectorization - Process 4-8 values per CPU instruction
- Zero-copy access -
CollectionsMarshal.AsSpan()exposes internal arrays
dotnet add package QuanTAlibusing QuanTAlib;
// Create EMA indicator
var ema = new Ema(period: 10);
// Streaming mode - process one value at a time
TValue result = ema.Update(new TValue(DateTime.Now, price), isNew: true);
// Update current bar (e.g., price tick within same minute)
result = ema.Update(new TValue(DateTime.Now, newPrice), isNew: false);
// Batch mode - process entire series
var series = new TSeries();
series.Add(prices); // Add historical data
TSeries emaResults = Ema.Calculate(series, period: 10);// Calculate multiple EMAs in parallel using SIMD
int[] periods = { 9, 12, 26 };
var emaVector = new EmaVector(periods);
// Single update calculates all periods
TValue[] results = emaVector.Update(new TValue(time, price));
Console.WriteLine($"EMA(9)={results[0]}, EMA(12)={results[1]}, EMA(26)={results[2]}");// Geometric Brownian Motion simulator
var gbm = new GBM(startPrice: 100, mu: 0.05, sigma: 0.2);
TBarSeries bars = gbm.Fetch(count: 1000, DateTime.UtcNow.Ticks, TimeSpan.FromMinutes(1));
// CSV file reader
var csv = new CsvFeed("data/daily_IBM.csv");
TBar bar = csv.Next(isNew: true);Copy DLL files to Quantower installation:
<Quantower_root>\Settings\Scripts\Indicators\QuanTAlib\Trends\Trends.dll
Where <Quantower_root> is the directory containing Start.lnk.
QuanTAlib/
├── lib/
│ ├── core/
│ │ ├── tvalue/ # TValue struct
│ │ ├── tseries/ # TSeries class
│ │ ├── tbar/ # TBar struct
│ │ ├── tbarseries/ # TBarSeries class
│ │ └── simd/ # SIMD extensions
│ ├── trends/
│ │ └── ema/ # EMA indicator + tests + docs
│ └── feeds/
│ ├── csv/ # CSV file feed
│ └── gbm/ # GBM simulator
└── quantower/ # Quantower integration
Each indicator follows a consistent file pattern:
Indicator.cs- Core implementationIndicator.Tests.cs- Unit testsIndicator.Validation.Tests.cs- Cross-validation with other librariesIndicator.md- DocumentationIndicator.Notebook.dib- Interactive notebookIndicator.Quantower.cs- Quantower wrapper
QuanTAlib validates results against established TA libraries:
- TA-LIB - Industry standard C library
- Skender Stock Indicators - Popular .NET library
- Tulip Indicators - High-performance C library
- .NET 8.0, 9.0, or 10.0
- Hardware with AVX/SSE support recommended for optimal SIMD performance
Apache License 2.0 - See LICENSE for details.
Contributions welcome! Each indicator should include:
- Core implementation with streaming support
- Unit tests covering edge cases
- Validation tests against reference libraries
- Documentation with mathematical formulas
- Quantower wrapper (optional)