Indicator Interface

All indicators derive from indicatorCore_c β€” a minimal virtual base class. Indicators are attached to OHLC series and updated automatically on each bar close.

The indicatorCore_c Base Class

Virtual Method Purpose
setParams(json) Configure the indicator from JSON parameters
getDataSize() Return the size of one data element in bytes
getData() Return pointer to the raw data buffer
update(ohlc, index) Compute the next value when a bar closes

The base class also provides data_move() β€” a helper that shifts the data buffer when older bars are evicted from the OHLC ring buffer. This keeps the indicator aligned with the OHLC data without manual index management.

// Every indicator derives from this class indicatorCore_c { public: virtual ~indicatorCore_c() = default; virtual void setParams( const boost::json::value& json ) = 0; virtual size_t getDataSize() const = 0; virtual const uint8_t* getData() const = 0; virtual void update( const ohlcFull_s* ohlc, int64_t newIndex ) = 0; };
πŸ”„ How Indicators Connect to OHLC
Indicators are configured per OHLC timeframe in the config file. Each ohlcInfo_s holds an array of indicatorInfo_s*. When a bar closes, the OHLC system calls update() on every attached indicator, passing the completed bar. Your algo accesses indicator values by referencing the OHLC + indicator by their config IDs β€” no direct pointer management needed.

Built-in Indicators

πŸ“ˆ

Moving Averages

Indicator Class
SMA Ind_AverageSMA
EMA indAverageEMA
WMA Ind_AverageWMA
HMA indAverageHMA
ZLHMA Ind_AverageZLHMA

5 moving average variants: simple, exponential, weighted, Hull, and zero-lag Hull. Configurable period for each.

πŸ“Š

Oscillators & Bands

Indicator Class
MACD Ind_Macd
RSI Ind_RSI
Bollinger Bands Ind_BollingerBand

MACD with signal line and histogram. RSI with configurable period. Bollinger Bands with configurable period and sigma multiplier.

πŸ“

Volatility & Range

Indicator Class
ATR Ind_AverageTrueRange
Bar Range Ind_AverageBarRange
Trading Range Ind_TradingRange

ATR for volatility-based stop placement. Bar range for intra-bar volatility. Trading range for support/resistance detection.

Accessing Indicators from Algos

The instrumentInfo_s struct provides convenience methods to retrieve indicator values without navigating the OHLC/indicator hierarchy manually.

πŸ”

Direct Value Access

Method Returns
GetIndicatorValue(ohlcId, indId, barIdx, valIdx) Value at a specific bar index
GetIndicatorValueWorking(ohlcId, indId, valIdx) Current (in-progress) bar value
GetIndicatorValueLast(ohlcId, indId, valIdx, offset) Most recent completed bar, with optional offset

ohlcId and indId are configInfo_s references β€” the same IDs used in the config file. valIdx selects which output value (e.g., 0 for MACD line, 1 for signal line, 2 for histogram).

πŸ—οΈ

OHLC & Bar Access

Method Returns
findOhlc(duration) Find OHLC series by timeframe
findOhlc(configId) Find OHLC series by config ID
GetOhlcWorking(configId) Current in-progress bar
GetOhlcLast(configId, offset) Completed bar with offset

Each ohlcFull_s contains the standard OHLC prices (ohlc), Heikin-Ashi prices (ohlcHA), volume, CVD, trade count, and timestamp. Bar analysis helpers: IsGreen(), IsRed(), getRange(), lengthBody(), lengthUpperWick(), lengthLowerWick().

πŸ’‘ Indicator Access Pattern
In your algo, store the configInfo_s IDs for your OHLC timeframe and indicators (parsed from onSetParams()). Then call e.g. instr->GetIndicatorValueLast(ohlcId, rsiId, 0) to get the latest RSI value, or instr->GetIndicatorValue(ohlcId, macdId, 5, 2) to get the MACD histogram from 5 bars ago. No pointers, no array indices β€” symbolic config IDs only.

Custom Indicators

Adding a custom indicator is straightforward: derive from indicatorCore_c, implement the four virtual methods, and register it in the indicator store.

1
Derive from indicatorCore_c
β†’
2
Implement setParams(), getDataSize(), getData(), update()
β†’
3
Register in the indicator store via config
β†’
4
Access from your algo by config ID

Data Buffer Management

Indicators own a fixed-size data buffer. The OHLC system maintains _OHLC_ITEM_COUNT (2048) bars total, keeping _OHLC_ITEM_KEEP (256) bars when rotating. The data_move() method shifts your indicator's data accordingly β€” you just implement the math in update().

Multi-value indicators (like MACD with line + signal + histogram) use getDataSize() to declare their element width. The framework handles the memory layout β€” your update() writes all output values for one bar.

// Custom stochastic oscillator example class Ind_Stochastic : public indicatorCore_c { struct Data { decimal_t k, d; }; Data m_buffer[_OHLC_ITEM_COUNT]; public: void setParams(const json::value& v) override { m_period = v.at("period").as_int64(); } size_t getDataSize() const override { return sizeof(Data); } const uint8_t* getData() const override { return (uint8_t*)m_buffer; } void update(const ohlcFull_s* o, int64_t i) override { // Compute %K and %D from OHLC data } };