Number Series
Number series represent numeric values aligned with each candle in time.
They are the foundation of all calculations in StockBeat.
A number series can come from:
- Raw market data (price, volume)
- Indicators (EMA, RSI, SMA)
- Arithmetic expressions combining other series
Every number series produces one numeric value per candle and can be freely chained with other expressions.
Price Series
Price series expose raw OHLC market data.
| Name | Arguments | Description | Example |
|---|---|---|---|
open | – | Opening price of the candle | open() |
high | – | Highest price of the candle | high() |
low | – | Lowest price of the candle | low() |
close | – | Closing price of the candle | close() |
volume | – | Volume of the candle | volume() |
mfi | period – number of candles | The MFI(Money Flow Index) is an volume and price based oscillator which gives money flow over n periods | mfi(14) |
atr | period – smoothing period of EMA (integer greater than 0) | Average true range (ATR). A technical analysis volatility indicator, originally developed by J. Welles Wilder. The average true range is an N-day smoothed moving average of the true range values. This implementation uses exponential moving average. | atr(14) |
cci | period – number of periods (integer greater than 0). Default is 20 | Commodity Channel Index (CCI). The commodity channel index is an oscillator originally introduced by Donald Lambert in 1980 | cci(20) |
ce | period - number of periods (integer greater than 0). Default is 22.multiplier ATR factor. Default is 3. | Chandelier Exit (CE).Developed by Charles Le Beau and featured in Alexander Elder's books, the Chandelier Exit sets a trailing stop-loss based on the Average True Range (ATR). The indicator is designed to keep traders in a trend and prevent an early exit as long as the trend extends. Typically, the Chandelier Exit will be above prices during a downtrend and below prices during an uptrend. | ce(22, 3, short) |
er | period - number of periods (integer greater than 0) | Kaufman's Efficiency Ratio (ER).It is calculated by dividing the price change over a period by the absolute sum of the price movements that occurred to achieve that change. The resulting ratio ranges between 0.0 and 1.0 with higher values representing a more efficient or trending market. | er(14) |
kc | period - number of periods (integer greater than 0).multiplier Usually 2. `type one of avg, up or low. For EMA use avg, for EMA + ATR of observation use up, for EMA - ATR of observation use low | Keltner Channel (KC).A Keltner Channel is an indicator showing the Average True Range (ATR) of a price surrounding a central moving average. The ATR bands are typically shown 'k' times moved away from the moving average. | kc(14, 2.0, avg) |
tr | - | The range of a day's trading is simply high - low. The true range extends it to yesterday's closing price if it was outside of today's range. The true range is the largest of one the following: Most recent period's high minus the most recent period's low Absolute value of the most recent period's high minus the previous close Absolute value of the most recent period's low minus the previous close | tr() |
Trend Indicators
Used to identify direction and trend strength.
| Name | Arguments | Description | Example |
|---|---|---|---|
sma | period – number of candles | Simple moving average | sma(50) |
ema | period – number of candles | Exponential moving average | ema(20) |
macd | period – number of candlesslow_period – period for slow EMAsignal_period – period of signal EMAtype one of macd, signal or histogram | Moving average converge divergence (MACD).The MACD indicator (or "oscillator") is a collection of three time series calculated from historical price data, most often the closing price | macd(12, 26, 9, histogram) |
ppo | period – number of candlesslow_period – period for slow EMAsignal_period – period of signal EMAtype one of macd, signal or histogram | Percentage Price Oscillator (PPO).The PPO indicator (or "oscillator") is a collection of three time series calculated from historical price data, most often the closing price | ppo(12, 26, 9) |
Momentum Indicators
Used to measure speed and exhaustion of price moves.
| Name | Arguments | Description | Example |
|---|---|---|---|
rsi | period – number of candles | The relative strength index (RSI). It is a momentum oscillator, that compares the magnitude of recent gains and losses over a specified time period to measure speed and change of price movements of a security. It is primarily used to attempt to identify overbought or oversold conditions in the trading of an asset. | rsi(21) |
fso | period – number of candles | Fast stochastic oscillator. The stochastic oscillator is a momentum indicator comparing the closing price of a security to the range of its prices over a certain period of time. | fso(14) |
sso | period – number of candlesema_period - period for EMA (integer greater than 0). Default is 3. | Slow stochastic oscillator. Basically it is a fast stochastic oscillator smoothed with exponential moving average. | sso(14, 3) |
Volatility Indicators
Used to understand price dispersion and expansion.
| Name | Arguments | Description | Example |
|---|---|---|---|
bb | period – number of candlesmultiplier - multiplier | A Bollinger Bands (BB). (BB). It is a type of infinite impulse response filter that calculates Bollinger Bands using Exponential Moving Average. The Bollinger Bands are represented by Average EMA and standard deviaton that is moved 'k' times away in both directions from calculated average value. | bb(9, 2.0) |
mad | period – number of candles | Mean Absolute Deviation (MAD).It is the average of the absolute deviations from a central point. It is a summary statistic of statistical dispersion or variability. | mad(9) |
Arithmetic Operators
Arithmetic operators allow you to manipulate number series using either:
- A scalar value
- Another number series
All arithmetic operators return a new number series.
| Name | Arguments | Description | Example |
|---|---|---|---|
add | rhs – scalar or number series | Adds two values | close().add(open()), close().add(5.5) |
sub | rhs – scalar or number series | Subtracts right-hand value | close().sub(open()), close().sub(5.5) |
mul | rhs – scalar or number series | Multiplies values | close().mul(open()), close().mul(1.5) |
div | rhs – scalar or number series | Divides values | close().div(open()), close().div(1.5) |
Chaining Number Series
Number series are designed to be composable.
You can chain multiple expressions to create derived values:
close().sub(ema(20))
Number series expressions follow strict chaining rules:
- Every expression returns a number series
- Scalars are only allowed as arguments
- Time alignment is implicit and automatic
- Missing values propagate safely
