Python indicator library¶
Use these functions inside a Python strategy's on_tick(). The platform supplies the names below when its TAP integration is available. Pass close, another price series, or complete bars explicitly. No import is needed for these supplied names.
The calls below show the standard settings. Python also accepts named arguments, such as rsi(close, period=14). Unless a row says container, the result is a series: use [0] for now and [1] for one bar ago. Read using indicators for a complete strategy and history checks.
Moving averages¶
All results use the input's units. The period is a bar count, not a threshold. In the calls below, omitting the period while keeping the input uses the period shown.
| Python call | What it calculates | Other defaults or distinctions |
|---|---|---|
sma(close, 20) |
Equal-weight arithmetic average of the window. | Needs a complete window. |
ema(close, 20) |
Exponentially weighted average. | alpha=None uses 2 / (period + 1); an explicit alpha overrides it. |
wma(close, 20) |
Average with linearly increasing weights toward recent observations. | Current-inclusive window. |
dema(close, 20) |
2 × EMA − EMA(EMA). |
Can overshoot the input. |
tema(close, 20) |
Combination of three successive EMAs. | Can overshoot the input. |
hull_ma(close, 14) |
Combination of weighted averages at half, full and square-root periods. | A smoothing choice, not a future price. |
kama(close, 14) |
Efficiency-adaptive average. | fast_ema=2, slow_ema=30. |
alma(close, 14) |
Gaussian-weighted average. | offset=0.85, std_dev=6. |
vidya(close, 14) |
R²-adaptive EMA. | r2_period=14. |
sine_weighted_moving_average(close, 14) |
Sine-weighted average. | Uses the full weighted window. |
zero_lag_ema(close, 20) |
EMA corrected by its difference from a second EMA. | Same DEMA construction in this implementation. |
zlema(close, 14) |
EMA of a lag-adjusted input. | Distinct from zero_lag_ema. |
vwma(bars, 14) |
Volume-weighted mean of close. | Requires close and volume together. |
To change an advanced setting, Python permits clear keyword calls: kama(close, period=14, fast_ema=2, slow_ema=30) or alma(close, period=14, offset=0.85, std_dev=6). Passing a single price series such as high selects that input without changing the default column="close" used by its calculation view.
Momentum and oscillators¶
| Python call | Result and units | Settings |
|---|---|---|
rsi(close, 14) |
Relative Strength Index, 0–100. | Wilder smoothing; default period 14. Flat price history reads 0 after its initial missing reading. |
roc(close, 14) |
Relative price change ×100, in percentage points. | Default lookback 14; needs 15 prices for that offset. |
momentum(close, 14) |
Current minus N-bars-ago price, in price units. | Default period 14; not cross-sectional ranking. |
ppo(close, 12, 26) |
Fast/slow EMA difference divided by slow EMA, ×100. | Fast period 12, slow period 26. |
tsi(close, 25, 13) |
Double-smoothed momentum relative to absolute momentum, ×100. | First smoothing 25, second 13. |
rmi(bars, 14, 5) |
Relative Momentum Index, normally 0–100. | Smoothing period 14, momentum offset 5. |
awesome(bars, 5, 34) |
Fast minus slow midpoint-price average, in price units. | Fast 5, slow 34; needs high and low. |
cci(bars, 20, 0.015) |
Typical-price deviation scaled by mean absolute deviation. Unbounded. | Period 20, scaling constant 0.015. |
williams_r(bars, 14) |
Close's location in its high–low range, −100 to 0. | Period 14; near 0 is near the window high. |
stc(bars, 23, 50, 10) |
Schaff Trend Cycle, a normalised smoothed cycle reading. | Fast EMA 23, slow EMA 50, cycle 10. |
modified_stochastic(bars, 14) |
Extra-smoothed stochastic %K. | Period 14; internally uses %D period 3; may overshoot the original scale. |
trix(close, 14, 9) |
Container: trix and signal series. |
Triple-smoothed rate of change; period 14, signal smoothing 9. Select a line before reading [0]. |
For TRIX in Python, trix(close, 14, 9)["trix"][0] reads the current TRIX line. String-key selection works on a Python result container; that form is not TradeScript expression syntax.
MACD and stochastic lines¶
Each supplied name in this table returns one series, so it can be passed to crossover or read with [0].
| Python call | Line selected | Settings and units |
|---|---|---|
macd(close, 12, 26, 9) |
Fast EMA minus slow EMA. | Fast 12, slow 26, signal 9; price units. |
macd_signal(close, 12, 26, 9) |
EMA of MACD. | Same parameters; price units. |
macd_hist(close, 12, 26, 9) |
MACD minus its signal. | Same parameters; price units. |
stochastic(bars, 14, 3, 1) |
%K. | Lookback 14, %D smoothing 3, multiplier 1; normally 0–100. |
stochastic_k(bars, 14, 3, 1) |
%K, identical to the supplied stochastic line. |
Multiplier scales the output. |
stochastic_d(bars, 14, 3, 1) |
SMA of %K. | Same arguments as %K. |
Keep matching parameters when comparing companion lines. macd(close, 12, 26, 9)[0] > macd_signal(close, 12, 26, 9)[0] checks their current ordering. For a transition use crossover on the series themselves.
Trend strength and direction¶
| Python call | Reading | Default period |
|---|---|---|
adx(bars, 14) |
ADX trend-strength line, normally 0–100; no up/down direction by itself. | 14 |
plus_di(bars, 14) |
Positive directional movement relative to true range, ×100. | 14 |
minus_di(bars, 14) |
Negative directional movement relative to true range, ×100. | 14 |
aroon(bars, 25) |
Aroon Up minus Aroon Down, −100 to 100. | 25 |
aroon_up(bars, 25) |
Recency of the window high, 0–100. | 25 |
aroon_down(bars, 25) |
Recency of the window low, 0–100. | 25 |
The supplied adx and aroon select a single line. Explicit TAP calls return their complete multi-line result instead.
Volatility and channels¶
| Python call | Result | Defaults and interpretation |
|---|---|---|
atr(bars, 14) |
Price-distance series. | Period 14; true range includes gaps against previous close. |
historical_volatility(close, 20, 252) |
Annualised log-return volatility ×100. | Lookback 20, observations per year 252; 20 means 20%, not 0.20. Choose an annualisation factor matching the input bars. |
bb_upper(close, 20, 2) |
Upper Bollinger price level. | SMA + 2 rolling sample standard deviations. |
bb_mid(close, 20) |
Middle Bollinger price level. | 20-bar SMA. |
bb_lower(close, 20, 2) |
Lower Bollinger price level. | SMA − 2 rolling sample standard deviations. |
donchian_upper(bars, 20) |
Highest high series. | Includes the current bar. |
donchian_mid(bars, 20) |
Midpoint of upper and lower series. | Period 20. |
donchian_lower(bars, 20) |
Lowest low series. | Includes the current bar. |
keltner_upper(bars, 20, 10, 2) |
Upper Keltner price level. | EMA period 20, ATR period 10, multiplier 2, in that order. |
keltner_mid(bars, 20, 10, 2) |
EMA centre. | Later ATR/multiplier arguments do not change this centre. |
keltner_lower(bars, 20, 10, 2) |
Lower Keltner price level. | EMA − multiplier × ATR. |
bollinger_bands(close, 20, 2) |
Container: upper, middle, lower. |
Same settings as the Bollinger component functions. |
donchian_channel(bars, 20) |
Container: upper, middle, lower. |
Same settings as the Donchian components. |
keltner_channel(bars, 20, 10, 2) |
Container: upper, middle, lower. |
Same EMA / ATR / multiplier order. |
A 20-return historical-volatility window needs 21 positive prices. Annualisation is not automatically adjusted for intraday or weekly bars. For an earlier-range breakout, close[0] > donchian_upper(bars, 20)[1] uses the window ending one bar ago. Without [1], the upper channel includes the current high.
Volume and extremes¶
| Python call | Result and units | Window or input |
|---|---|---|
vwap(bars) |
Volume-weighted typical-price series. | Cumulative over supplied history; does not reset automatically each session. |
vwap(bars, 20) |
Rolling volume-weighted typical-price series. | Latest 20 bars, using (high + low + close) / 3. |
obv(bars) |
Cumulative signed volume series. | No period argument; rises/falls with close direction. |
mfi(bars, 14) |
Money Flow Index, 0–100. | Period 14; uses typical price and volume. |
cmf(bars, 20) |
Chaikin Money Flow ratio, normally −1 to 1. | Period 20; not a 0–100 oscillator. |
force_index(bars, 13) |
Smoothed close change × volume. | EMA period 13; units are price × volume. |
highest_n(bars, "high", 20) |
Rolling maximum series. | Input, column, period; includes now. |
lowest_n(bars, "low", 20) |
Rolling minimum series. | Input, column, period; includes now. |
Volume inputs must be meaningful for the instrument. An OBV value is sensitive to the start of history; VWAP's cumulative form is too. For scalar rolling calculations and crossing helpers, see the helper reference.
Current restrictions¶
Some supplied component names can produce a TS007 “assumed injected provider” advisory in Python diagnostics. This is an advisory rather than a blocking syntax error. Check the spelling against this page and confirm the indicator integration is available; a diagnostic alone does not establish runtime support.
modified_rsi(close, 14) is supplied but currently produces missing readings on ordinary close history, even after a long warmup. Use rsi until the underlying calculation is corrected. This limitation applies to an explicit TAP call too.
barssince(rsi(close, 14) > 70) receives a single current Boolean, not a historical Boolean series. It cannot reconstruct the event's history. barssince needs a genuine Boolean history input.
This page covers the 42 supplied base names and their 17 additional component functions. It is not the complete TAP catalog. Python can explicitly import additional functions from tap.atom; read more indicators with TAP for that separate usage. Helpers, data and execution still require the appropriate strategy context.