Stock Indicators for .NET

repository·main·Indexed 22 days ago

https://github.com/facioquo/stock-indicators-dotnet

A C# library for calculating financial market technical indicators (such as Moving Averages, RSI, Stochastic Oscillator, and Parabolic SAR) from OHLCV price bars. It supports batch processing (Series), incremental calculations (BufferList), and real-time streaming (StreamHub) for trading algorithms, machine learning, and charting. Available via NuGet as FacioQuo.Stock.Indicators (formerly Skender.Stock.Indicators).

Tokens
112.3K
Snippets
313
Records
538
Agent score
78%

What's inside stock-indicators-dotnet

  1. Overview of Skender.Stock.Indicators v2 API coverage

    main

    The test application exercises a wide range of technical indicators and utility methods available in the v2 API.

    Indicators Tested

    The application covers over 200 indicators across various categories, including:

    • Trend/Momentum: ADX, EMA, MACD, RSI, SMA, Stochastic, etc.
    • Volatility: ATR, Bollinger Bands, Keltner, StdDev, etc.
    • Volume/Flow: ADL, CMF, OBV, VWAP, etc.
    • Specialized: Ichimoku, Renko, ZigZag, etc.

    Input Variations

    Indicators are tested using:

    • Default parameters: Standard/recommended settings.
    • Custom parameters: Non-default values.
    • Quote inputs: Standard OHLCV data.
    • Tuple inputs: Simplified (DateTime, double) pairs where supported.
    • Enum parameters: Various enumeration types such as EndType, BetaType, ChandelierType, MaType, PeriodSize, and PivotPointType.

    Utility Methods

    Quote Utilities

    • Use(): Extract candle part values.
    • ToSortedCollection(): Sort and convert quotes.
    • ToTupleCollection(): Convert to tuples.
    • Aggregate(): Aggregate to larger periods.
    • Validate(): Validate quote data.
    • ToCandle() / ToCandles(): Convert to candle properties.
    • Find(): Find specific quote by date.

    Result Utilities

    • ToTupleChainable(): Convert reusable results to tuples.
    • ToTupleNaN(): Convert with NaN handling.
    • Find(): Find specific result by date.
  2. Explore available technical indicators and overlays

    main

    The Stock Indicators for .NET library provides a comprehensive suite of financial market technical analysis methods. These are categorized into several functional groups to help you identify price patterns, momentum, volatility, and trends:

    • Price Trends: Tools for trend identification (e.g., Alligator, Aroon, ADX, Ichimoku Cloud, MACD, SuperTrend).
    • Price Channels: Tools for defining price range boundaries (e.g., Bollinger Bands®, Donchian Channels, Keltner Channels, Pivot Points).
    • Oscillators: Tools for measuring momentum and strength (e.g., RSI, Stochastic Oscillator, CCI, Awesome Oscillator).
    • Stop and Reverse: Tools for identifying pivots and potential direction changes (e.g., Parabolic SAR, ATR Trailing Stop, Chandelier Exit).
    • Candlestick Patterns: Recognition of specific price shapes (e.g., Doji, Marubozu, Williams Fractal).
    • Volume-based: Measures that incorporate volume data (e.g., VWAP, OBV, Money Flow Index, Chaikin Money Flow).
    • Moving Averages: Price smoothing techniques (e.g., SMA, EMA, Hull Moving Average, ALMA, Kaufman's Adaptive Moving Average).
    • Price Transforms: Conversions of price form (e.g., Heikin Ashi, Renko Charts, ZigZag, Bar transforms like HL2/OHLC4).
    • Price Characteristics: Traits and behaviors of price (e.g., ATR, Historical Volatility, Rate of Change, Choppiness Index).
    • Numerical Analysis: Fundamental mathematical calculations for financial analysis (e.g., Beta coefficient, Correlation, Linear Regression, Standard Deviation, Z-score).
  3. Explore Stop and Reverse indicators

    main

    The Stop and Reverse category includes indicators designed to signal trend reversals and define dynamic exit or stop levels. Available indicators in this category include:

    • ATR Trailing Stop: ATR-based adaptive trailing stop bands.
    • Chandelier Exit: Volatility-based trailing stop loss exit levels covering both long and short positions.
    • Parabolic SAR: Accelerating trend and reversal stops.
    • SuperTrend: ATR trend-following breakpoint thresholds around an HL2 midline.
    • Volatility Stop: ATR-based adaptive trailing stop bands (also known as Wilder's Volatility System).
  4. Available candlestick pattern indicators

    main

    The library provides several specific candlestick pattern indicators, each focusing on different price formations:

    • Doji: Identifies indecision candles where the open and close prices are virtually identical.
    • Marubozu: Identifies uni-directional solid-body momentum candles with consistent price movement.
    • Pivots: Identifies peak and trough chevron patterns. These are configurable with period wings and identification for higher highs or lower lows.
    • Fractal (Williams): Identifies peak and trough chevron patterns using fixed $\pm 2$ period wings for short-term pivots.
  5. Explore Price Characteristics indicators

    main

    The Price Characteristics category contains indicators designed to measure intrinsic price properties such as volatility, momentum, and trendiness. Use these indicators to gauge market conditions and price movement characteristics.

    Available indicators in this category include:

    • Average True Range (ATR): Tracks typical price movement size to gauge market volatility.
    • Balance of Power (BOP): Measures buying and selling pressure from the open-to-close price change.
    • Bull & Bear Power (Elder-ray Index): Depicts buying/selling pressure.
    • Choppiness Index (CHOP): Compares cumulative price movement to overall range to gauge trendiness.
    • Dominant Cycle Periods: Uses Hilbert Transform methods to estimate the dominant cycle period.
    • Historical Volatility (HV): Standard deviation of returns, including Z-score.
    • Hurst Exponent: Long-memory persistence measure (aka Rescaled Range Analysis).
    • Price Momentum Oscillator (PMO): Double-smoothed momentum indicator based on Rate of Change (ROC).
    • Price Relative Strength (PRS): Ratio of price histories to a market or sector benchmark price.
    • Rate of Change (ROC) and Momentum: Relative percent (ROC) and absolute (MO) price change, aka Momentum Oscillator (MO).
    • Rate of Change with Bands: Volatility banded Rate of Change (ROC) with EMA signal line.
    • True Range (TR): Single-period true range price values.
    • True Strength Index (TSI): Double-smoothed momentum direction and overbought / oversold conditions.
    • Ulcer Index (UI): Measures downside price volatility (often called the "heart attack" score).
  6. Explore Price Transform indicators

    main

    Price transforms are indicators that convert or reshape price data into alternative chart forms. The library provides several categories of transforms:

    • Basic price bar transforms: Computes alternative OHLCV components like HL2, HLC3, OC2, OHL3, and OHLC4.
    • Ehlers Fisher Transform: Performs Gaussian normalization of price.
    • Heikin Ashi: A modified candlestick transform that uses prior period price for smoothing.
    • Renko Charts: A Japanese candlestick transform that uses "bricks" in a non-linear time series.
    • ZigZag: Simplifies high-low plot lines based on user-defined percent change thresholds.
  7. Explore Numerical Analysis indicators

    main

    For statistical and mathematical analysis of price data, the library provides several numerical analysis tools. These are often used in conjunction with price characteristics to provide deeper statistical context.

    Available numerical analysis indicators include:

    • Beta coefficient (β)
    • Coefficient of determination
    • Correlation coefficient
    • Linear regression (best-fit line)
    • Mean absolute deviation (MAD)
    • Mean absolute percentage error (MAPE)
    • Mean square error (MSE)
    • R-squared (R²)
    • Slope (gradient)
    • Standard deviation (σ)
    • Z-score (standard score)
  8. Explore Price Characteristic indicators

    main

    Beyond pure numerical analysis, the library provides several indicators focused on price characteristics. These can be used to analyze momentum, volatility, and cycle periods:

    • Volatility & Range: Average True Range (ATR), Normalized ATR, True Range (TR), and Historical Volatility (HV).
    • Momentum & Strength: Rate of Change (ROC), Rate of Change with Bands (ROC-WB), Momentum Oscillator (MO), Price Momentum Oscillator (PMO), and True Strength Index (TSI).
    • Relative Strength: Comparative Relative Strength and Price Relative Strength (PRS).
    • Market Dynamics: Balance of Power (BOP), Bull and Bear Power (Elder Ray), Choppiness Index (CHOP), Hurst Exponent, and Ulcer Index (UI).
  9. Explore Volume-based indicators

    main

    The stock-indicators-dotnet library provides several volume-weighted indicators that incorporate trading activity into price analysis. These indicators help identify buying and selling pressure, money flow, and volume momentum.

    Available volume-based indicators include:

    • Accumulation Distribution Line (ADL): A cumulative CMF volume pressure line.
    • Chaikin Money Flow (CMF): A Simple Moving Average (SMA) of directional Money Flow Volume, representing volume-weighted buying/selling pressure.
    • Chaikin Oscillator: An Exponential Moving Average (EMA) of the Accumulation/Distribution Line (ADL).
    • Force Index: Measures buying and selling pressure based on the change in price and trade volume.
    • Klinger Volume Oscillator (KVO): Used for long/short-term volume momentum, trend reversal, and divergence of money flow.
    • Money Flow Index (MFI): A volume-weighted relative strength of positive and negative money flow.
    • On-Balance Volume (OBV): A rolling accumulative sum of directionally signed volume.
    • Price Volume Oscillator (PVO): The rate of change between two converging/diverging EMAs of volume (similar to MACD but for volume).
    • Volume-weighted average price (VWAP): The volume-weighted average of price, typically used for intraday data analysis.
    • Volume-weighted moving average (VWMA): An average price adjusted by volume over a rolling window period.
  10. Understand the Common utilities and patterns directory structure

    main

    The Common/ directory contains the foundational infrastructure used by all indicators in the library. It is organized into several functional areas:

    • BarPart: Extraction of specific candle components (Open, High, Low, Close, Volume, etc.) via IBarPart and streaming hubs like BarPartHub.
    • Bars: Core OHLCV bar types (IBar, Bar), aggregation logic (BarAggregatorHub), and source hubs (BarHub).
    • BufferLists: Incremental processing logic using BufferList for managing data windows.
    • Candles: Utilities for candlestick pattern recognition.
    • Catalog: Metadata and discovery API via Catalog.Get() and Catalog.Listings.
    • Enums: Shared types like BarInterval, CandlePart, and Direction.
    • Reusable: Core interfaces for time-stamped records (ISeries) and single-value chainable records (IReusable).
    • StreamHub: The primary framework for real-time streaming indicators, providing IStreamHub for management and IStreamObservable/IStreamObserver for push/pull data flow.
    • TradeTicks: Raw trade-tick types and specialized hubs for tick-to-bar quantization.
  11. Use Numerical Analysis indicators for financial modeling

    main

    The stock-indicators-dotnet library provides a suite of numerical analysis tools for fundamental mathematical calculations in financial analysis. These indicators are used to quantify market sensitivity, statistical relationships, and trend strength.

    Key categories of numerical analysis available include:

    • Beta coefficient (β): Measures expected price sensitivity relative to the broader market (includes $\beta+$ and $\beta-$).
    • Correlation coefficients: Includes Pearson correlation, R-squared ($R^2$), variance, and covariance.
    • Linear regression & Slope: Uses ordinary least-squares simple linear regression to determine the slope of a best-fit line, useful for identifying trend direction and strength.
    • Error metrics (SMA analysis): Includes Mean Absolute Deviation (MAD), Mean Square Error (MSE), and Mean Absolute Percentage Error (MAPE).
    • Volatility measures: Includes Standard Deviation ($\sigma$) of returns and Z-scores, often used as Historical Volatility (HV).
  12. Explore Price Channel indicators

    main

    The stock-indicators-dotnet library provides several types of price channel indicators, which are envelope and band indicators used to define price range boundaries around a trend.

    Available price channel indicators include:

    • Bollinger Bands®: Volatility-based boundaries using standard deviation from a moving average of price.
    • Donchian Channels: Price ranges derived from the highest High and lowest Low (also known as Price Channels).
    • Fractal Chaos Bands (FCB): Fractal-based high and low price channels depicting less-chaotic price movement.
    • Keltner Channels: ATR (Average True Range) channels centered around an EMA (Exponential Moving Average).
    • Moving Average Envelopes: Percentage offsets applied around various moving average types.
    • Pivot Points: Classic support/resistance levels based on fixed calendar periods (available in multiple styles).
    • Rolling Pivot Points: Support/resistance levels based on a rolling window period.
    • STARC Bands: ATR channels centered around an SMA (Simple Moving Average).
    • Standard Deviation Channels: Standard Deviation Channels segmented by rolling window periods.