Architecture
This page provides an overview of OnlineTechnicalIndicators.jl's architecture, including module organization and type hierarchy.
Module Overview
OnlineTechnicalIndicators.jl is organized into several submodules, each with a specific responsibility:
OnlineTechnicalIndicators (main module)
├── Candlesticks # OHLCV data structures
├── Internals # Internal utility functions
├── Indicators # Technical indicators (60+)
├── Patterns # Candlestick pattern recognition
├── Wrappers # Indicator wrappers (Smoother, DAGWrapper)
├── Factories # Factory functions (MovingAverage)
└── SampleData # Sample OHLCV data for testingModule Relationships
Type Hierarchy
All technical indicators inherit from a common type hierarchy rooted in OnlineStatsBase.OnlineStat.
Abstract Types
# From OnlineStatsBase
abstract type OnlineStat{T} end
# Base type for all technical indicators
abstract type TechnicalIndicator{T} <: OnlineStat{T} end
# Single output indicators (e.g., SMA, RSI)
abstract type TechnicalIndicatorSingleOutput{T} <: TechnicalIndicator{T} end
# Multiple output indicators (e.g., MACD, BB)
abstract type TechnicalIndicatorMultiOutput{T} <: TechnicalIndicator{T} end
# Moving average indicators
abstract type MovingAverageIndicator{T} <: TechnicalIndicatorSingleOutput{T} endType Hierarchy Diagram
Submodule Details
Candlesticks
Provides OHLCV (Open, High, Low, Close, Volume) data structures.
Exports:
OHLCV: Candlestick data structure with optional timestampOHLCVFactory: Factory for batch OHLCV creation from vectorsValueExtractor: Module with extraction functions (extract_open,extract_close, etc.)
using OnlineTechnicalIndicators.Candlesticks
# Create a single candlestick
candle = OHLCV(100.0, 105.0, 98.0, 103.0; volume=1000.0, time=Date(2024,1,1))
# Create from vectors
factory = OHLCVFactory(opens, highs, lows, closes; volume=volumes)
candles = collect(factory)Internals
Internal utilities for indicator implementation. While exported for advanced use cases, the API may change between minor versions.
Type Queries:
is_multi_input(T): Check if indicator requires OHLCV inputis_multi_output(T): Check if indicator produces multiple valuesexpected_return_type(ind): Get return type of an indicator
Value Utilities:
has_output_value(ind): Check if indicator has valid outputhas_valid_values(buf, window): Check circular buffer validityis_valid(x): Check if value is not missing
Calculation Functions:
_fit!: Internal fit function for OnlineStatsBase integration_calculate_new_value: Calculate value from internal state_calculate_new_value_only_from_incoming_data: Calculate from incoming data only
Indicators
Contains 60+ technical indicators organized by input/output type. See Indicators support for the complete list.
Categories:
- SISO (Single Input, Single Output): SMA, EMA, RSI, etc.
- SIMO (Single Input, Multiple Output): BB, MACD, StochRSI, KST
- MISO (Multiple Input, Single Output): ATR, OBV, MFI, etc.
- MIMO (Multiple Input, Multiple Output): Stoch, ADX, SuperTrend, etc.
Patterns
Contains 13 candlestick pattern detectors. See Candlestick Pattern Recognition for details.
Categories:
- Single Candle: Doji, Hammer, ShootingStar, Marubozu, SpinningTop
- Two Candle: Engulfing, Harami, PiercingDarkCloud, Tweezer
- Three Candle: Star, ThreeSoldiersCrows, ThreeInside
- Composite: CandlestickPatternDetector (detects all patterns)
Wrappers
Provides wrapper types for composing indicators.
Exports:
Smoother: Generic wrapper that applies a moving average to any indicator's outputDAGWrapper: Wrapper for StatDAG integration withfit!infrastructure
using OnlineTechnicalIndicators.Wrappers
# Create a smoother (applies SMA to TrueRange output)
smoother = Smoother(TrueRange; period=14, ma=SMA)
for candle in ohlcv_data
fit!(smoother, candle)
endFactories
Factory functions for creating indicator instances.
Exports:
MovingAverage: Factory for creating typed moving average indicatorsMAFactory: Deprecated alias forMovingAverage
using OnlineTechnicalIndicators.Factories
factory = MovingAverage(Float64)
ma = factory(SMA, period=10) # Creates SMA{Float64}(period=10)SampleData
Sample OHLCV data for testing and examples.
Exports:
OPEN_TMPL,HIGH_TMPL,LOW_TMPL,CLOSE_TMPL,VOLUME_TMPL: Price/volume vectorsV_OHLCV: Vector of OHLCV candlesticksTAB_OHLCV: Tables.jl-compatible sample data
using OnlineTechnicalIndicators.SampleData
candles = SampleData.V_OHLCV
prices = SampleData.CLOSE_TMPLExternal Dependencies
OnlineStatsBase.jl
Provides the foundational OnlineStat abstract type and core utilities:
fit!: Update a statistic with new datavalue: Get the current valuenobs: Get the number of observationsCircBuff: Circular buffer for rolling windows
OnlineStatsChains.jl
Provides StatDAG for composing indicators into directed acyclic graphs with automatic value propagation. Used internally by composed indicators like DEMA, TEMA, T3, and TRIX.
Tables.jl
Enables integration with any Tables.jl-compatible data source (DataFrames, CSV, etc.).
See Also
- Project Structure for the directory layout
- Data Flow for how data flows through indicators
- OnlineTechnicalIndicators internals for implementation details