forge.ta
Indicator functions, their classes and the missing-value helpers (contract C3).
Naming convention (04 IND-029, written once): functions are short and lower case (``ta.rsi``); indicator classes are CapWords (``RSI``); PEP 8 throughout; parameters run source first, then periods, then methods (``ta.ma(source, period, method)``), the order MetaTrader 5 uses.
Missing values are ``NaN`` in arrays and ``None`` for a scalar that has no value (contract C1 section 2). ``fg.nz`` and ``fg.isna`` resolve here, so strategies and indicators share one missing-value helper (contract C2 section 1).
Time: bar times are ``bars.time`` (open) and ``bars.time_close``, int64 nanoseconds UTC (contract C1 section 2). ``ta.hour``, ``ta.dayofweek`` and ``ta.month`` read them in a zone and ``ta.timestamp`` builds one. On non-time bars (Renko and the like) a bar's own times are not the market's, so read ``bars.real.time`` for time logic (IND-194).
Built-in library: every function is ``forge_indicators.<name>``, and every class wraps one and is generated from ``forge_indicators.REGISTRY`` (contract C3 section 4). ``ta.sma`` is the package's function, so the moving average on a chart is the one that was tested.
| Name | Kind | Summary |
|---|---|---|
| isna | function | True where a value is missing: ``None`` or ``NaN``. |
| nz | function | Replace a missing value with ``value`` (default 0). |
| AC | class | How fast the Awesome oscillator is speeding up or slowing down. |
| ADR | class | The average high to low range of recent trading days. |
| ADX | class | How strong the trend is, whatever its direction. |
| ALMA | class | Gaussian weighted average whose peak you can move toward the newest bar. |
| AO | class | Momentum from the gap between a fast and a slow average of the median price. |
| ATR | class | The average true range over a period, Wilder smoothed or simple. |
| AccDist | class | Volume weighted by where the close sits in the bar. |
| Alligator | class | Three smoothed lines that show when a trend is asleep or waking up. |
| Aroon | class | How recently the highest high and the lowest low happened. |
| BWMFI | class | Price range per unit of volume, with Bill Williams' four colours. |
| BearsPower | class | The bar's low against an EMA of closes. |
| BollingerBands | class | A moving average with bands set by the standard deviation. |
| BollingerPercentB | class | Where the price sits between the Bollinger Bands. |
| BollingerWidth | class | The distance between the Bollinger Bands relative to the middle line. |
| BullsPower | class | The bar's high against an EMA of closes. |
| CCI | class | Distance from the average in units of mean deviation. |
| CMO | class | Up moves against down moves over a period, from -100 to 100. |
| ChaikinOscillator | class | The fast average of A/D minus its slow average. |
| Change | class | Value now minus the value a number of bars ago. |
| Cum | class | The total of every value from the first bar. |
| DEMA | class | Exponential average with part of its lag removed. |
| DMI | class | Trend direction as two lines, with the strength of the trend. |
| DarkCloudCover | class | A fall that closes deep into the previous rise. |
| DeMarker | class | Pressure from higher highs against lower lows, from 0 to 1. |
| Delay | class | The series moved a number of bars back. |
| Doji | class | A bar whose body is tiny against its range. |
| Donchian | class | Highest high and lowest low of the last N bars, with their midpoint. |
| DragonflyDoji | class | A doji that opens and closes near its high. |
| EMA | class | Average that weights recent values more, each step closing part of the gap to the price. |
| EfficiencyRatio | class | How directly the price moved: 1 for a straight line, near 0 for noise. |
| Engulfing | class | A body that covers the previous opposite body. |
| Envelopes | class | A moving average with a band a set distance above and below it. |
| EveningDojiStar | class | An evening star whose middle bar is a doji. |
| EveningStar | class | A long rise, a small star, then a fall into the rise. |
| FRAMA | class | Average that follows trends closely and flattens in chop, from the fractal dimension. |
| FairValueGaps | class | Three-candle imbalances, shown until price fills them. |
| Falling | class | True after a number of falls in a row. |
| ForceIndex | class | Volume times the change of a moving average of price. |
| Fractals | class | Swing highs and lows, shown two bars after they form. |
| Gator | class | How far apart the Alligator's jaw, teeth and lips are. |
| GravestoneDoji | class | A doji that opens and closes near its low. |
| HMA | class | Fast, smooth average built from two weighted averages. |
| Hammer | class | A long lower wick after a fall. |
| HangingMan | class | A long lower wick after a rise. |
| Harami | class | A small body inside the previous long body. |
| HeikinAshi | class | Smoothed candles that make trends easier to read. |
| Highest | class | The highest value over a number of bars. |
| HighestBars | class | How many bars ago the highest value of the window was. |
| Ichimoku | class | Five lines that show trend, momentum and support in one view. |
| InsideBar | class | A bar whose range sits within the previous bar's range. |
| InvertedHammer | class | A long upper wick after a fall. |
| KAMA | class | Average that speeds up when the price trends and slows down when it chops. |
| Keltner | class | An EMA with bands set by the average true range. |
| KeltnerWidth | class | The distance between the Keltner bands relative to the middle line. |
| Killzones | class | Named session windows, each in its own time zone, shaded on the chart and usable as filters. |
| LinReg | class | Least squares line fitted to the last N values, read at the newest bar. |
| LinRegIntercept | class | Where the fitted line starts, at the oldest bar of the window. |
| LinRegSlope | class | How much the fitted line rises or falls per bar. |
| Liquidity | class | Equal highs and lows (EQH, EQL), resting liquidity above swing highs and below swing lows, and the sweeps that take it. |
| LogReturn | class | The natural log of the value over the previous value. |
| Lowest | class | The lowest value over a number of bars. |
| LowestBars | class | How many bars ago the lowest value of the window was. |
| MA | class | Any of the eight moving averages, chosen by name. |
| MACD | class | The gap between a fast and a slow EMA, with a signal line and histogram. |
| MFI | class | RSI built from price times volume, from 0 to 100. |
| MarketStructure | class | Confirmed swings labelled HH, HL, LH and LL, with breaks of structure (BOS) and changes of character (CHoCH), for internal and swing structure. |
| Marubozu | class | A bar with almost no wicks, rising or falling. |
| Median | class | Middle value of the last N values, so one spike cannot move it. |
| MidPoint | class | Halfway between the highest and lowest value of a window. |
| MidPrice | class | Halfway between the highest high and the lowest low of a window. |
| Momentum | class | Price now against price a number of bars ago. |
| MorningDojiStar | class | A morning star whose middle bar is a doji. |
| MorningStar | class | A long fall, a small star, then a rise into the fall. |
| OBV | class | Volume added on up closes and taken away on down closes. |
| OpeningRange | class | The high and low of the first minutes of a session, with breakout signals. |
| OrderBlocks | class | The last opposite candle before a break of structure, kept until price trades back through it. |
| OsMA | class | The MACD histogram: MACD minus its signal line. |
| OutsideBar | class | A bar whose range covers the previous bar's range. |
| PercentRank | class | Where the value sits among its previous values, from 0 to 100. |
| PeriodOpen | class | The opening price of the current day, week or month. |
| Piercing | class | A rise that closes deep into the previous fall. |
| PivotHigh | class | A swing high, shown once enough bars after it prove it was the highest. |
| PivotLow | class | A swing low, shown once enough bars after it prove it was the lowest. |
| PivotPoints | class | Support and resistance levels projected from the previous day, week or month. |
| PremiumDiscount | class | The upper and lower halves of the active swing range, split at equilibrium. |
| PriorLevels | class | The previous day, week or month open, high, low and close (PDH, PDL), carried forward. |
| RMA | class | Wilder's smoothing: a slow average seeded with the mean of the first N values. |
| ROC | class | Change over a number of bars as a percent, fraction or ratio. |
| RSI | class | Momentum bounded 0 to 100, from average gains against average losses. |
| RVI | class | The close against the open, scaled by the range, with a signal line. |
| Rising | class | True after a number of rises in a row. |
| SAR | class | Trailing stop-and-reverse level that speeds up as the trend runs. |
| SMA | class | Average of the last N values, each weighted equally. |
| SessionRange | class | The high and low of the Asia, London and New York sessions, boxed while each runs. |
| ShootingStar | class | A long upper wick after a rise. |
| SpinningTop | class | A small body with a longer wick on each side. |
| StdDev | class | How far values spread around their average over a period. |
| StochRSI | class | The stochastic oscillator applied to RSI. |
| Stochastic | class | Where the close sits in the recent high to low range, with a signal line. |
| Sum | class | The sum of the last values over a number of bars. |
| SuperTrend | class | Trend-following line built from the average true range. |
| TEMA | class | Exponential average with most of its lag removed. |
| TRIX | class | The one-bar change of a triple smoothed EMA. |
| ThreeBlackCrows | class | Three falling bars, each opening inside the last body. |
| ThreeInside | class | A harami confirmed by the third bar. |
| ThreeOutside | class | An engulfing confirmed by the third bar. |
| ThreeWhiteSoldiers | class | Three rising bars, each opening inside the last body. |
| TrueRange | class | The largest of the bar's range and its gaps from the previous close. |
| VIDYA | class | Exponential average that speeds up when momentum is strong. |
| VWAP | class | The average price weighted by volume since the session, week, month or a chosen time. |
| VWMA | class | Average that weights each price by the volume traded at it. |
| Variance | class | The square of the standard deviation over a period. |
| Volumes | class | Volume per bar, tick or real as the feed carries it. |
| WMA | class | Average that weights the newest value N times and the oldest once. |
| WilliamsR | class | Where the close sits in the recent range, from 0 down to -100. |
| ZigZag | class | Swing highs and lows, each shown only once a reversal has confirmed it. |
| ac | function | Accelerator oscillator: the Awesome oscillator minus its own ``signal_period`` average. |
| accdist | function | Accumulation and distribution: a running total of volume weighted by the close's position. |
| adr | function | Average daily range: the mean high to low range of the last ``days`` finished trading days. |
| adx | function | The ADX line of ``dmi``: how strong the trend is, whatever its direction. |
| alligator | function | Bill Williams' Alligator: ``jaw``, ``teeth`` and ``lips``. |
| alma | function | Arnaud Legoux average: Gaussian weights over ``window`` bars. |
| ao | function | Awesome oscillator: the fast average of the median price minus the slow one. |
| aroon | function | Aroon: how recently the highest high and the lowest low of the last ``period + 1`` bars came. |
| atr | function | Average true range, Wilder smoothed (``wilder``) or a simple mean (``sma``). |
| barssince | function | How many bars ago the condition last held: 0 on a bar where it holds. |
| bb | function | Bollinger Bands: a simple average with bands ``deviations`` population deviations away. |
| bb_percent | function | Bollinger Bands %B: ``(source - lower) / (upper - lower)``. |
| bbw | function | Bollinger Bands width: ``(upper - lower) / middle``. |
| bears_power | function | Bears power: the bar's low minus an EMA of the closes. |
| bulls_power | function | Bulls power: the bar's high minus an EMA of the closes. |
| bw_mfi | function | Market facilitation index: ``mfi = (high - low) / volume``, in price units. |
| cci | function | Commodity channel index: distance from the average in units of mean deviation. |
| chaikin_osc | function | Chaikin oscillator: the fast average of accumulation and distribution minus the slow one. |
| change | function | Value now minus the value ``period`` bars ago. |
| cmo | function | Chande momentum oscillator: up moves against down moves over ``period`` bars, -100 to 100. |
| correlation | function | Rolling correlation of two series over the last ``period`` bars, from -1 to 1. |
| cross | function | 1 on a bar where ``a`` crosses above ``b``, -1 where it crosses below, 0 elsewhere. |
| crossover | function | True on the bar where ``a`` goes from at or below ``b`` to above it. |
| crossunder | function | True on the bar where ``a`` goes from at or above ``b`` to below it. |
| cum | function | The running total of the source from the first bar. |
| dark_cloud_cover | function | Dark cloud cover: a fall that closes deep into the previous rise. |
| dayofweek | function | The weekday of ``t`` in ``tz``, Monday 0 to Sunday 6 (the engine clock's convention). |
| delay | function | The source ``n`` bars ago: ``value[i] = source[i - n]``. |
| dema | function | Double exponential average: ``2 * EMA - EMA(EMA)``, the second stage seeded at bar ``period - 1``. |
| demarker | function | DeMarker: pressure from higher highs against lower lows, from 0 to 1. |
| dmi | function | Directional movement: ``plus_di``, ``minus_di`` and ``adx``. |
| doji | function | Doji: a bar whose body is tiny against its range. |
| donchian | function | Donchian channel: highest high and lowest low of the last ``period`` bars, and their mean. |
| dragonfly_doji | function | Dragonfly doji: a doji that opens and closes near its high. |
| efficiency_ratio | function | Net move over ``period`` bars divided by the path length. |
| ema | function | Exponential average: ``k = 2 / (period + 1)``, seeded with the first price. |
| engulfing | function | Engulfing: a body that covers the previous opposite body. |
| envelopes | function | A moving average with a band above and below it. |
| evening_doji_star | function | Evening doji star: an evening star whose middle bar is a doji. |
| evening_star | function | Evening star: a long rise, a small star, then a fall into the rise. |
| fair_value_gaps | function | Three-candle gaps, newest first in five slots per side, until price fills them. |
| falling | function | True when each of the last ``period`` bars is below the bar before it. |
| force | function | Force index: the volume times the change of a moving average of the price. |
| fractals | function | Williams fractals: ``up`` (swing high) and ``down`` (swing low), written two bars late. |
| frama | function | Fractal adaptive average of the close (Ehlers). |
| gator | function | Gator oscillator: the gaps between the Alligator's lines, above and below 0. |
| gravestone_doji | function | Gravestone doji: a doji that opens and closes near its low. |
| hammer | function | Hammer: a long lower wick after a fall. |
| hanging_man | function | Hanging man: a long lower wick after a rise. |
| harami | function | Harami: a small body inside the previous long body. |
| heikin_ashi | function | Heikin-Ashi candles: ``ha_open``, ``ha_high``, ``ha_low`` and ``ha_close``. |
| highest | function | The highest value of the last ``period`` bars, the current bar included. |
| highest_bars | function | How many bars ago the highest value of the last ``period`` bars was, 0 for the current bar. |
| hma | function | Hull average: ``wma(2 * wma(x, half) - wma(x, period), root)``. |
| hour | function | The hour (0 to 23) of nanosecond UTC times ``t`` in the zone ``tz``. |
| ichimoku | function | Tenkan, kijun, senkou A and B, and chikou, undisplaced. |
| inside_bar | function | Inside bar: a bar whose range sits within the previous bar's range. |
| inverted_hammer | function | Inverted hammer: a long upper wick after a fall. |
| kama | function | Kaufman adaptive average. |
| kc | function | Keltner channel: an EMA of closes with bands ``atr_factor`` average true ranges away. |
| kcw | function | Keltner channel width: ``(upper - lower) / middle``. |
| killzones | function | Four named windows, each true on the bars that open inside it. |
| linreg | function | The regression line at the newest bar of the window: ``a + b * (period - 1)``. |
| linreg_intercept | function | The regression line at the oldest bar of the window. |
| linreg_slope | function | The slope of the regression line: its change per bar. |
| liquidity | function | Equal highs and lows, resting liquidity above swing highs and below swing lows, and sweeps. |
| log_return | function | The natural log of the value over the previous value: ``ln(source[i] / source[i-1])``. |
| lowest | function | The lowest value of the last ``period`` bars, the current bar included. |
| lowest_bars | function | How many bars ago the lowest value of the last ``period`` bars was, 0 for the current bar. |
| lwma | function | Linearly weighted average: weight ``period`` on the newest value down to 1 on the oldest. |
| ma | function | The moving average named by ``method``: one of sma, ema, smma, lwma, wma, hma, dema, tema. |
| macd | function | MACD: the fast EMA minus the slow EMA, its signal line and the gap between them. |
| market_structure | function | Swings labelled HH, HL, LH and LL, with breaks of structure and changes of character. |
| marubozu | function | Marubozu: a bar with almost no wicks. |
| max2 | function | The larger of two series bar by bar, or of a series and a number. |
| median | function | Median of the last ``period`` values. |
| mfi | function | Money flow index: RSI built from the typical price times volume, from 0 to 100. |
| midpoint | function | Halfway between the highest and the lowest value of the last ``period`` bars. |
| midprice | function | Halfway between the highest high and the lowest low of the last ``period`` bars. |
| min2 | function | The smaller of two series bar by bar, or of a series and a number. |
| mom | function | Price now against price ``period`` bars ago. |
| month | function | The month (1 to 12) of ``t`` in ``tz``. |
| morning_doji_star | function | Morning doji star: a morning star whose middle bar is a doji. |
| morning_star | function | Morning star: a long fall, a small star, then a rise into the fall. |
| obv | function | On-balance volume: a running total that starts with the first bar's volume. |
| opening_range | function | The high and low of the first minutes of a session, and the closes that cross them. |
| order_blocks | function | The last opposite candle before each break of structure, kept until price goes through it. |
| osma | function | OsMA: the MACD line minus its signal line. |
| outside_bar | function | Outside bar: a bar whose range covers the previous bar's range. |
| percentrank | function | The share of the previous ``period`` values at or below the current value. |
| period_open | function | The open of the current day, week or month on every bar of it. |
| piercing | function | Piercing line: a rise that closes deep into the previous fall. |
| pivot_high | function | The high of a swing high, written ``right`` bars after the swing. |
| pivot_low | function | The low of a swing low, written ``right`` bars after the swing (the mirror of pivot_high). |
| pivot_points | function | Pivot points for ``kind`` from the previous ``period`` (``D``, ``W`` or ``M``). |
| premium_discount | function | The upper and lower halves of the active swing range, split at equilibrium. |
| prior_levels | function | The previous day's, week's or month's open, high, low and close on every bar. |
| rising | function | True when each of the last ``period`` bars is above the bar before it. |
| rma | function | Wilder's smoothed average: seeded with the mean of the first ``period`` values. |
| roc | function | Change over ``period`` bars, as a percent, a fraction or a ratio. |
| rsi | function | Relative strength index from average gains against average losses, 0 to 100. |
| rvi | function | Relative vigor index: the close against the open, scaled by the range, with a signal line. |
| sar | function | Parabolic stop and reverse. |
| session_range | function | The Asia, London and New York sessions: a box while each runs, its levels once it ends. |
| shooting_star | function | Shooting star: a long upper wick after a rise. |
| sma | function | Mean of the last ``period`` values, each window summed from scratch. |
| smma | function | Wilder's smoothed average: seeded with the mean of the first ``period`` values. |
| spinning_top | function | Spinning top: a small body with a longer wick on each side. |
| stdev | function | Standard deviation of the last ``period`` values around their moving average at this bar. |
| stoch | function | Stochastic oscillator: ``k`` is the slowed %K and ``d`` its simple average. |
| stoch_rsi | function | The stochastic oscillator applied to the relative strength index. |
| sum | function | The sum of the last ``period`` values. |
| supertrend | function | SuperTrend: a line ``factor`` average true ranges from the bar's midpoint that only ratchets. |
| tema | function | Triple exponential average: ``3 * E1 - 3 * E2 + E3``. |
| three_black_crows | function | Three black crows: three falling bars, each opening inside the last body. |
| three_inside | function | Three inside: a harami confirmed by the third bar. |
| three_outside | function | Three outside: an engulfing confirmed by the third bar. |
| three_white_soldiers | function | Three white soldiers: three rising bars, each opening inside the last body. |
| timestamp | function | Nanoseconds UTC of a local time in ``tz``. |
| tr | function | True range: the bar's range widened to take in the gap from the previous close. |
| trix | function | TRIX: the one-bar change of a triple smoothed EMA, as a fraction and not a percent. |
| valuewhen | function | The source on the bar where the condition last held, or the ``occurrence``-th time before. |
| variance | function | Variance: the mean squared distance of the last ``period`` values from their average. |
| vidya | function | Chande's variable index dynamic average. |
| volumes | function | The volume of each bar, and whether it is above the previous bar's. |
| vwap | function | Volume-weighted average price from each anchor, with bands at its weighted deviation. |
| vwma | function | Volume weighted average: ``sum(price * volume) / sum(volume)`` over the last ``period`` bars. |
| wilder | function | Wilder's smoothed average: seeded with the mean of the first ``period`` values. |
| wma | function | Linearly weighted average: weight ``period`` on the newest value down to 1 on the oldest. |
| wpr | function | Williams %R: where the close sits in the recent range, from 0 down to -100. |
| zigzag | function | Swing highs and lows, written only once a reversal confirms them. |