86 indicators in 7 groups, each computed by the engine with no lookahead, drawn on the chart and read by a strategy by its id. Where TA-Lib has an indicator it follows TA-Lib's definition, warm up included; where it does not, the original author's published formula. Every entry names its reference.
Reading one in a strategy
Every indicator is read by its id with its inputs by name; an input left out takes its default. One line reads as a number, None while it warms up (NaN in C#). Several lines read as a reading: each line by its name, and .value for the first. The same call in each language, with the inputs of Bollinger Bands:
textPython ctx.ind("bb", length=20, mult=2.0, source="close").upper
C# Indicators.Ind("bb", new { length = 20, mult = 2.0, source = "close" })["upper"]
Rust ctx.reading("bb", &[("length", 20.into()), ("mult", 2.0.into()), ("source", "close".into())])["upper"]
Formula ind("bb", "upper", length=20, mult=2.0, source="close")
IR {"ind": "bb", "inputs": {"length": 20, "mult": 2.0, "source": "close"}, "out": "upper"}In Blocks each indicator is a block of its own, in the "+" menu by group. How a reading behaves, and what a formula may pass, is on the Indicators API page.
Overview
Trend, 21 indicators
| Indicator | Id | What it measures |
|---|---|---|
| Simple moving average (SMA) | sma | The plain average of the last prices over the chosen length, a smoothed line that shows the direction of the trend. |
| Exponential moving average (EMA) | ema | An average of recent prices that gives the newest bars the most weight, so it follows price sooner than a simple average of the same length. |
| Weighted moving average (WMA) | wma | An average of recent prices in which the weight falls in a straight line from the newest bar to the oldest. |
| Hull moving average (HMA) | hma | Alan Hull's moving average, built to follow price with little lag while staying smooth. |
| Double exponential moving average (DEMA) | dema | Patrick Mulloy's double exponential average, which removes part of the lag of an ordinary EMA. |
| Triple exponential moving average (TEMA) | tema | Patrick Mulloy's triple exponential average, with even less lag than DEMA. |
| Triangular moving average (TRIMA) | trima | A doubly smoothed average whose weights rise towards the middle of the window and fall again, very smooth and slower than an SMA. |
| Kaufman adaptive moving average (KAMA) | kama | Perry Kaufman's adaptive average: it moves fast when price trends cleanly and almost stops when price only swings back and forth. |
| Tillson T3 moving average | t3 | Tim Tillson's T3, a smooth average with little lag made of six EMAs in a row. |
| Wilder's moving average (RMA) | rma | Welles Wilder's moving average, a slow exponential average that RSI, ATR and ADX use inside. |
| Volume weighted moving average (VWMA) | vwma | An average of recent prices in which each bar counts in proportion to the volume traded on it. |
| Arnaud Legoux moving average (ALMA) | alma | Arnaud Legoux's moving average: a bell shaped weighting moved towards the newest bars, meant to be smooth and responsive at once. |
| SuperTrend | supertrend | A trailing line from the ATR that sits below price in an uptrend and above it in a downtrend, and changes side when price breaks through it. |
| Parabolic SAR (PSAR) | psar | Welles Wilder's Parabolic stop and reverse: a trailing stop that closes in on price faster the longer a trend runs, and changes side when it is hit. |
| Ichimoku Kinko Hyo | ichimoku | Goichi Hosoda's Ichimoku Kinko Hyo: five lines for trend, momentum and support or resistance at once; the area between span A and span B is the cloud. |
| Aroon | aroon | Tushar Chande's Aroon: how many bars have passed since the highest high and since the lowest low, as two lines from 0 to 100. |
| Directional movement index (DMI) | dmi | Welles Wilder's directional movement: +DI and -DI show which side moves more, the ADX how strong the trend is, whatever its direction. |
| Linear regression (LinReg) | linreg | The end point of the straight line that fits the last bars best, a moving average that follows the trend with little lag. |
| Vortex indicator (VI) | vortex | Botes and Siepman's vortex indicator: two lines that compare upward with downward price movement to catch the start of a trend. |
| Heikin Ashi (HA) | heikin_ashi | Heikin Ashi candles, averaged candles that smooth the bars so a trend reads as a run of one colour, with their direction and how long the run has lasted. |
| Renko bricks | renko | Renko bricks: a brick of fixed size each time the close has moved that far, ignoring time, so only moves of at least one brick show. |
Momentum, 18 indicators
| Indicator | Id | What it measures |
|---|---|---|
| Relative strength index (RSI) | rsi | How strongly the recent closes rose against how strongly they fell, on a scale from 0 to 100. |
| Moving average convergence divergence (MACD) | macd | The gap between a fast and a slow exponential average of price, with a signal line and a histogram, to show the direction of a trend and when it gains or loses pace. |
| Stochastic oscillator | stoch | Where the close sits within the high to low range of the last bars, from 0 at the lowest low to 100 at the highest high. |
| Stochastic RSI (StochRSI) | stochrsi | Where the RSI sits within its own range of the last bars, from 0 at its lowest to 100 at its highest. |
| Commodity channel index (CCI) | cci | How far the typical price is from its average, in units of its mean deviation, scaled so that most values fall between -100 and 100. |
| Rate of change (ROC) | roc | How much price has changed over the last bars, in percent. |
| Momentum (MOM) | mom | How far price has moved over the last bars, in price units. |
| Williams %R | willr | Where the close sits within the high to low range of the last bars, on a scale from 0 at the highest high to -100 at the lowest low. |
| True strength index (TSI) | tsi | The smoothed bar to bar price change against the smoothed size of those changes, from -100 to 100: the direction of momentum and how steady it is. |
| Ultimate oscillator (UO) | uo | Buying pressure against the true range over three lengths at once, weighted toward the shortest, on a scale from 0 to 100. |
| Awesome oscillator (AO) | ao | The gap between a short and a long simple average of the bar midpoints: whether recent momentum is stronger or weaker than the longer term one. |
| Chande momentum oscillator (CMO) | cmo | The balance of up moves against down moves over the last bars, from -100 when every change was down to 100 when every change was up. |
| Percentage price oscillator (PPO) | ppo | The gap between a fast and a slow exponential average as a percentage of the slow one: MACD in percent, so it can be compared across markets and price levels. |
| TRIX | trix | The bar to bar change of a triple smoothed exponential average, in percent: the slope of the trend with most short term noise removed. |
| Absolute price oscillator (APO) | apo | The gap between a fast and a slow exponential average of price, in price units: the MACD line without its signal. |
| Balance of power (BOP) | bop | How far each bar closed from its open, against its full range, averaged over the last bars: whether buyers or sellers controlled the bars. |
| Detrended price oscillator (DPO) | dpo | How far price stands above or below its moving average with the trend taken out, to show the shorter cycles and their length. |
| Coppock curve | coppock | A smoothed sum of two long rates of change, made by Coppock to spot the end of bear markets on monthly charts of a stock index. |
Volatility, 12 indicators
| Indicator | Id | What it measures |
|---|---|---|
| Average true range (ATR) | atr | How far price typically moves in one bar, gaps from the previous close included, averaged over the length. |
| Bollinger Bands (BB) | bb | A moving average with a band above and below it whose width follows the price's standard deviation, so the bands widen when price swings and narrow when it calms down. |
| Normalized average true range (NATR) | natr | The average true range as a percentage of the close, so the typical bar size can be compared across markets and price levels. |
| True range (TR) | tr | The full range of a single bar, including any gap from the previous close. |
| Bollinger %B | bbp | Where the price sits within the Bollinger Bands: 0 at the lower band, 1 at the upper band, 0.5 at the middle. |
| Bollinger BandWidth (BBW) | bbw | How wide the Bollinger Bands are relative to their middle band. |
| Keltner Channels (KC) | kc | A channel around an exponential moving average whose width is a multiple of the average true range. |
| Donchian Channels (DC) | dc | The highest high and the lowest low of the last bars, with their midpoint. |
| Standard deviation (StdDev) | stddev | How widely the price spreads around its own average over the length, in price units. |
| Chaikin volatility (CHV) | chv | How fast the average bar range is growing or shrinking, as a percentage change. |
| Historical volatility (HV) | hv | How much the closes have moved from bar to bar, as an annualised volatility in percent, the unit options traders quote. |
| Choppiness index (CHOP) | chop | Whether the market is trending or moving sideways, on a scale from 0 to 100. |
Volume, 10 indicators
| Indicator | Id | What it measures |
|---|---|---|
| On balance volume (OBV) | obv | Whether volume goes with rising or with falling closes: a running total that adds a bar's volume when the close rises and takes it off when the close falls. |
| Volume weighted average price (VWAP) | vwap | The average price paid since the start of the current day, week or month, each bar weighted by its volume. |
| Accumulation/distribution line (A/D) | ad | Whether volume comes with closes near the high or near the low of each bar: a running total of buying and selling pressure. |
| Chaikin oscillator (ADOSC) | adosc | The momentum of the accumulation/distribution line: whether buying or selling pressure is building up or fading. |
| Chaikin money flow (CMF) | cmf | The share of the volume of the last n bars that came with closes near the high rather than near the low, from minus 1 to plus 1. |
| Money flow index (MFI) | mfi | A volume weighted RSI: how much money flowed on bars with a rising typical price against all the money that flowed, on a scale from 0 to 100. |
| Elder force index (EFI) | efi | The force behind a move: the change of the close times the volume, smoothed, so a large move on heavy volume counts more than the same move on little volume. |
| Ease of movement (EOM) | eom | How easily price moves for the volume traded: a large move on little volume is easy, a small move on heavy volume is hard. |
| Volume oscillator (VO) | vo | Whether volume is picking up or drying up: how far a fast average of volume is above or below a slow one, in percent. |
| Price volume trend (PVT) | pvt | Like on balance volume, but each bar adds volume in proportion to the percentage change of the close, so small moves count little. |
Levels, 2 indicators
| Indicator | Id | What it measures |
|---|---|---|
| Pivot points (Pivots) | pivots | Support and resistance levels for the current day, week or month, worked out from the high, low and close of the one before. |
| ZigZag | zigzag | The swing highs and lows that a reversal of at least the set percentage has confirmed, drawn as a level that steps to each new swing. |
Market structure, 19 indicators
| Indicator | Id | What it measures |
|---|---|---|
| Market structure (BoS/CHoCH) | structure | The swing highs and lows, the trend they form and the bars where price breaks them: a break of structure (BoS) with the trend, a change of character (CHoCH) against it. |
| Fair value gaps (FVG) | fvg | Three bar price gaps: ranges price jumped over so fast that the first and the third candle do not overlap, which often act as support or resistance when price comes back. |
| Inversion fair value gaps (iFVG) | ifvg | Fair value gaps that price has closed through, kept as zones of the opposite side: a bullish gap broken down turns into resistance, a bearish gap broken up into support. |
| Order blocks (OB) | order_block | The last opposite coloured candle before the move that broke structure, the zone where the move started and price often reacts when it comes back. |
| Breaker blocks | breaker_block | Order blocks that failed: price closed through them, and they are kept as zones of the opposite side, a broken bullish block as resistance, a broken bearish one as support. |
| Fibonacci retracement | fib_retracement | How far price has pulled back into the last swing leg, at the Fibonacci ratios 0.236, 0.382, 0.5, 0.618 and 0.786 between the last confirmed swing high and low. |
| Fibonacci extension (Fib ext) | fib_extension | Targets beyond the last swing leg: where the leg ends if it runs on 1.272, 1.618, 2 or 2.618 times its own length, measured from its start. |
| Premium and discount (P/D) | premium_discount | The dealing range between the last swing high and low, its middle (equilibrium) and whether price is in the upper half, premium, or the lower half, discount. |
| Optimal trade entry (OTE) | ote | The optimal trade entry zone: the 0.62 to 0.79 retracement of the last swing leg, where a pullback offers the best price before the leg resumes. |
| Liquidity sweep (Sweep) | liquidity_sweep | Stop runs: bars that trade beyond a swing high or low still holding liquidity and close back inside, the stops taken and the move rejected. |
| Equal highs and lows (EQH/EQL) | equal_levels | Liquidity pools: two or more swing highs (or lows) at about the same price, where the stops of many traders sit together and price is drawn to take them. |
| Buy and sell side liquidity (Liquidity) | liquidity | Where the resting stops are: the nearest swing high no later price has traded above (buy side) and the nearest swing low none has traded below (sell side). |
| Balanced price range (BPR) | bpr | Balanced price ranges: the overlap of a bullish and a bearish fair value gap, a range price has crossed fast in both directions and often reacts to when it returns. |
| Mitigation blocks (MB) | mitigation_block | The candle that made a swing, after a failure swing breaks that swing: traders trapped there wait to get out at break even, so price often turns when it comes back. |
| Rejection blocks (RB) | rejection_block | The long wick at a swing high or low, where price was pushed back hard; the range from the body to the wick's tip often rejects price again. |
| Displacement | displacement | Displacement: a candle with a body far larger than usual that leaves a fair value gap behind, the footprint of large orders moving price in one go. |
| Kill zones | killzones | The ICT kill zones, the hours when the big centres move price most: Asia, the London open, the New York open and the London close, and each zone's high and low. |
| Midnight open | midnight_open | The true day open of ICT: the price at 00:00 New York, and whether the close is above or below it, the reference for premium and discount within the day. |
| Opening gaps (NWOG/NDOG) | opening_gaps | The new week opening gap (NWOG) between Friday's close and the week's first open, and the new day opening gap (NDOG) between a day's last close and the next day's first open. |
Time, 4 indicators
| Indicator | Id | What it measures |
|---|---|---|
| Trading sessions (Sessions) | sessions | Which of the four FX centres is open on each bar, whether London and New York overlap, and the high and low of the session you follow, so far and of the last one. |
| Prior period levels | prior_levels | The open, high, low and close of the last finished day, week or month, and the open, high and low of the running one so far. |
| Opening range (OR) | opening_range | The high and low of the first minutes after a market opens, the range's middle and size, the size against a daily ATR, and where the close is against the range. |
| Seasonality | seasonality | How the instrument did in the past in periods like the current one: the mean return, the share that went up and a t statistic for the bar's month, weekday, turn of the month or hour. |
Trend
Simple moving average (SMA)
sma, drawn on the price.
What it measures. The plain average of the last prices over the chosen length, a smoothed line that shows the direction of the trend.
Formula. The sum of the source (the close by default) over the last length bars, divided by the length, every bar weighted the same. The first value comes once length bars are in, as TA-Lib's SMA.
How to read it. Price above a rising average points to an uptrend, below a falling one to a downtrend. It lags: the longer it is, the smoother it gets and the later it turns. In a sideways market price crosses it often and the crossings mean little.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. sma (SMA).
In a strategy. A trend filter that only allows longs while the close is above ctx.ind("sma", length=200), or the cross of a fast and a slow SMA as entry signal.
The call with every input at its default:
pythonctx.ind("sma", length=20, source="close")Reference: TA-Lib SMA.
Exponential moving average (EMA)
ema, drawn on the price.
What it measures. An average of recent prices that gives the newest bars the most weight, so it follows price sooner than a simple average of the same length.
Formula. Each bar the EMA moves towards the new price by the factor 2 / (length + 1): price times the factor plus the previous EMA times one minus the factor. It is seeded with the simple average of the first length prices, so its first value comes on the same bar as the SMA's, as TA-Lib's EMA. Older prices never drop out entirely, their weight shrinks every bar.
How to read it. The slope shows the trend, price above or below the line the side the market is on. It reacts sooner than an SMA and so also turns falsely more often in a sideways market.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. ema (EMA).
In a strategy. Crosses of a fast and a slow EMA as entry and exit, ctx.ind("ema", length=12) against ctx.ind("ema", length=26), or a pullback to a 20 bar EMA in a trend as entry point.
The call with every input at its default:
pythonctx.ind("ema", length=20, source="close")Reference: TA-Lib EMA.
Weighted moving average (WMA)
wma, drawn on the price.
What it measures. An average of recent prices in which the weight falls in a straight line from the newest bar to the oldest.
Formula. Over the last length bars the newest price weighs length, the one before length minus 1, down to 1 for the oldest. The weighted sum is divided by the sum of the weights, length times (length + 1) / 2. Prices older than the window drop out completely. The first value comes once length bars are in, as TA-Lib's WMA.
How to read it. It turns sooner than an SMA or EMA of the same length, its average lag being about a third of the window instead of a half. Slope and the side price is on give the trend; like every average it lags and whipsaws in a range.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. wma (WMA).
In a strategy. A quicker trend line or crossover partner: the close against ctx.ind("wma", length=20), or a cross of a short and a long WMA as entry signal.
The call with every input at its default:
pythonctx.ind("wma", length=20, source="close")Reference: TA-Lib WMA.
Hull moving average (HMA)
hma, drawn on the price.
What it measures. Alan Hull's moving average, built to follow price with little lag while staying smooth.
Formula. Two WMAs of the source, one over half the length (rounded down), one over the full length. Twice the short one minus the long one cancels most of the lag, and that difference is smoothed again with a WMA over the square root of the length, rounded down. The first value needs length plus that root minus 1 bars.
How to read it. The direction of the line is the main reading: a turn shows a change of trend early. Because it removes lag by extrapolating, it overshoots at sharp turns and can run past price; in a sideways market it turns often.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 9 | 2 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. hma (HMA).
In a strategy. The slope as trend signal: compare ctx.ind("hma", length=21) with its value a bar earlier and hold longs while it rises.
The call with every input at its default:
pythonctx.ind("hma", length=9, source="close")Reference: Hull 2005.
Double exponential moving average (DEMA)
dema, drawn on the price.
What it measures. Patrick Mulloy's double exponential average, which removes part of the lag of an ordinary EMA.
Formula. Twice the EMA of the source minus the EMA of that EMA, both with the same length. Each EMA is seeded with the simple average of its own first length inputs, so the second starts length minus 1 bars after the first and the first value needs 2 times length minus 1 bars, as TA-Lib's DEMA.
How to read it. Read like an EMA, but it follows price more closely and turns sooner; the cost is more overshoot at turns and more false signals in a range. Despite the name it is not an EMA applied twice.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. dema (DEMA).
In a strategy. A quicker trend line, ctx.ind("dema", length=20), with a cross of the close over it as entry trigger and a slower average as filter.
The call with every input at its default:
pythonctx.ind("dema", length=20, source="close")Reference: TA-Lib DEMA (Mulloy 1994).
Triple exponential moving average (TEMA)
tema, drawn on the price.
What it measures. Patrick Mulloy's triple exponential average, with even less lag than DEMA.
Formula. Three EMAs of the same length in a chain: e1 of the source, e2 of e1, e3 of e2. TEMA is 3 times e1 minus 3 times e2 plus e3. Each EMA is seeded with the simple average of its own first length inputs, so the first value needs 3 times length minus 2 bars, as TA-Lib's TEMA.
How to read it. It hugs price and turns early; at sharp turns it overshoots, and in a sideways market it turns falsely often. It suits places where speed matters more than smoothness.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. tema (TEMA).
In a strategy. A fast trend line with its slope as signal, ctx.ind("tema", length=20), combined with a slow filter such as an SMA 200.
The call with every input at its default:
pythonctx.ind("tema", length=20, source="close")Reference: TA-Lib TEMA (Mulloy 1994).
Triangular moving average (TRIMA)
trima, drawn on the price.
What it measures. A doubly smoothed average whose weights rise towards the middle of the window and fall again, very smooth and slower than an SMA.
Formula. An SMA of an SMA that together cover length bars. For an odd length both are (length + 1) / 2 long, so length 5 weighs the prices 1 2 3 2 1; for an even length one is length / 2 long and the other length / 2 + 1, so length 4 weighs 1 2 2 1. The first value comes once length bars are in, as TA-Lib's TRIMA.
How to read it. It shows the underlying trend or cycle with little noise but turns late, about half a window after price. Better for seeing the trend than for timing entries.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. trima (TRIMA).
In a strategy. A slow trend filter, for example longs only while ctx.ind("trima", length=30) is rising, or the centre line for bands of your own.
The call with every input at its default:
pythonctx.ind("trima", length=20, source="close")Reference: TA-Lib TRIMA.
Kaufman adaptive moving average (KAMA)
kama, drawn on the price.
What it measures. Perry Kaufman's adaptive average: it moves fast when price trends cleanly and almost stops when price only swings back and forth.
Formula. The efficiency ratio ER is the absolute net change over length bars divided by the sum of the absolute bar to bar changes, 1 when nothing moved. The factor is (ER times (2/(fast+1) minus 2/(slow+1)) plus 2/(slow+1)) squared, and KAMA moves that share of the way to the price each bar. As TA-Lib's KAMA the first value needs length + 1 bars and starts from the previous price; fast 2 and slow 30 are TA-Lib's fixed values.
How to read it. A flat KAMA means noise, a sloping one a trend. Price crossing it says more than with a fixed average because the line barely moves in a range, but after a long flat phase it reacts late to a breakout.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 10 | 1 to 5000 |
| Fast length | fast | 2 | 1 to 500 |
| Slow length | slow | 30 | 1 to 500 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. kama (KAMA).
In a strategy. A trend filter or trailing line: go long when the close crosses above ctx.ind("kama", length=10, fast=2, slow=30) while the line itself is rising.
The call with every input at its default:
pythonctx.ind("kama", length=10, fast=2, slow=30, source="close")Reference: TA-Lib KAMA (Kaufman 1995).
Tillson T3 moving average
t3, drawn on the price.
What it measures. Tim Tillson's T3, a smooth average with little lag made of six EMAs in a row.
Formula. Six EMAs of the same length in a chain, each smoothing the one before. With the volume factor a, T3 is c1 e6 + c2 e5 + c3 e4 + c4 e3 where c1 = -a^3, c2 = 3a^2 + 3a^3, c3 = -6a^2 - 3a - 3a^3 and c4 = 1 + 3a + a^3 + 3a^2. Each EMA is seeded with the simple average of its own first length inputs, so the first value needs 6 times length minus 5 bars, as TA-Lib's T3.
How to read it. Smoother than an EMA with similar lag. A volume factor of 0 leaves just the third EMA of the chain, higher values remove more lag at the cost of more overshoot; 0.7 is Tillson's choice. Turns of the slope are the main signal.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 5 | 1 to 5000 |
| Volume factor | vfactor | 0.7 | 0.0 to 1.0 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. t3 (T3).
In a strategy. A smooth trend line, ctx.ind("t3", length=5, vfactor=0.7): long while its slope points up, flat when it turns down.
The call with every input at its default:
pythonctx.ind("t3", length=5, vfactor=0.7, source="close")Reference: TA-Lib T3 (Tillson 1998).
Wilder's moving average (RMA)
rma, drawn on the price.
What it measures. Welles Wilder's moving average, a slow exponential average that RSI, ATR and ADX use inside.
Formula. Each bar the new value is the previous one times (length minus 1) plus the price, divided by length: an exponential average with the factor 1 / length. It is seeded with the simple average of the first length prices, so the first value comes once length bars are in. Apart from the seed it equals an EMA of length 2 times length minus 1.
How to read it. Read like any moving average, only slower: an RMA 14 reacts about like an EMA 27. On a chart it is mostly useful to follow or check the smoothing inside Wilder's indicators.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 14 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. rma (RMA).
In a strategy. Smoothing in Wilder's style, or a slow trend line: the close against ctx.ind("rma", length=14).
The call with every input at its default:
pythonctx.ind("rma", length=14, source="close")Reference: Wilder 1978 (RMA, SMMA).
Volume weighted moving average (VWMA)
vwma, drawn on the price, needs volume.
What it measures. An average of recent prices in which each bar counts in proportion to the volume traded on it.
Formula. The sum of price times volume over the last length bars, divided by the sum of the volume over the same bars. The first value comes once length bars are in. When no volume traded in the whole window the line has no value on that bar.
How to read it. Against an SMA of the same length it leans towards the prices where most volume traded: a VWMA above the SMA means the volume came with rising prices. For forex and CFDs the volume is usually tick volume, which only roughly stands for real turnover.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. vwma (VWMA).
In a strategy. Compare ctx.ind("vwma", length=20) with ctx.ind("sma", length=20) and allow longs only while the VWMA is above, as a sign that volume carries the move.
The call with every input at its default:
pythonctx.ind("vwma", length=20, source="close")Reference: Volume weighted moving average.
Arnaud Legoux moving average (ALMA)
alma, drawn on the price.
What it measures. Arnaud Legoux's moving average: a bell shaped weighting moved towards the newest bars, meant to be smooth and responsive at once.
Formula. Each bar of the window weighs exp(-(i - m)^2 / (2 s^2)), with i from 0 for the oldest bar to length minus 1 for the newest, m = offset times (length minus 1) and s = length / sigma. The weighted sum of the prices is divided by the sum of the weights. The first value comes once length bars are in.
How to read it. The offset moves the peak of the weighting: near 1 the line follows price closely, near 0 it is smooth and slow. A larger sigma narrows the bell, so fewer bars matter. Slope and the side price is on are read as with any average.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 9 | 1 to 5000 |
| Offset | offset | 0.85 | 0.0 to 1.0 |
| Sigma | sigma | 6.0 | 0.5 to 50.0 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. alma (ALMA).
In a strategy. A responsive trend line, ctx.ind("alma", length=9, offset=0.85, sigma=6), or the cross of two ALMAs of different lengths as entry signal.
The call with every input at its default:
pythonctx.ind("alma", length=9, offset=0.85, sigma=6.0, source="close")Reference: Legoux 2009.
SuperTrend
supertrend, drawn on the price.
What it measures. A trailing line from the ATR that sits below price in an uptrend and above it in a downtrend, and changes side when price breaks through it.
Formula. The basic bands are the bar's midpoint (high plus low, halved) plus and minus mult times the ATR, Wilder's ATR seeded with the mean of the first length true ranges. The upper band only moves down and the lower only up, unless the previous close broke through. An uptrend turns down when the close falls below the lower band, a downtrend up when it closes above the upper. First value on bar length, counting from 0; direction is +1 up, -1 down.
How to read it. The line is the stop of the current trend, and a change of side is the signal. In strong trends it keeps a position open; in sideways markets it flips often and each flip costs. A larger multiplier means fewer and later flips.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| ATR length | length | 10 | 1 to 5000 |
| Multiplier | mult | 3.0 | 0.1 to 20.0 |
Lines. supertrend (SuperTrend) and direction (Direction, read by a strategy, not drawn).
In a strategy. Trend following on the flip: long when ctx.ind("supertrend", length=10, mult=3.0).direction turns from -1 to 1, with .supertrend as the trailing Stop-Loss.
The call with every input at its default:
pythonsupertrend = ctx.ind("supertrend", length=10, mult=3.0)
supertrend.supertrend, supertrend.directionReference: Seban (SuperTrend).
Parabolic SAR (PSAR)
psar, drawn on the price.
What it measures. Welles Wilder's Parabolic stop and reverse: a trailing stop that closes in on price faster the longer a trend runs, and changes side when it is hit.
Formula. Each bar the stop moves towards the trend's extreme point by af times the gap; af starts at acceleration and grows by it on every new extreme, up to maximum. A low at or under the stop (a high at or over it when short) reverses: the stop jumps to the old extreme. It never enters the range of this bar or the one before. As TA-Lib's SAR the first bar only seeds and the second picks the side from the directional movement; direction is +1 long, -1 short.
How to read it. Dots below price mark a long trend, above price a short one, and a switch is a reversal signal. It works in clean trends and gets whipsawed in ranges, where it is always in the market. A higher acceleration pulls the stop in tighter.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Acceleration | acceleration | 0.02 | 0.001 to 1.0 |
| Maximum | maximum | 0.2 | 0.001 to 1.0 |
Lines. sar (SAR) and direction (Direction, read by a strategy, not drawn).
In a strategy. As a trailing Stop-Loss: exit a long when the close falls below ctx.ind("psar", acceleration=0.02, maximum=0.2).sar, or trade the switches of .direction with a trend filter.
The call with every input at its default:
pythonpsar = ctx.ind("psar", acceleration=0.02, maximum=0.2)
psar.sar, psar.directionReference: TA-Lib SAR (Wilder 1978).
Ichimoku Kinko Hyo
ichimoku, drawn on the price.
What it measures. Goichi Hosoda's Ichimoku Kinko Hyo: five lines for trend, momentum and support or resistance at once; the area between span A and span B is the cloud.
Formula. Conversion and base are the midpoint of the highest high and lowest low over their lengths, span A their mean, span B the midpoint over the longest window, the lagging line the close. Each value at a bar comes from bars up to it; the chart only draws the spans displacement bars ahead and the lagging line as far back. The conversion line starts first, base and spans once their windows are full.
How to read it. Price above the cloud is read as an uptrend, below it as a downtrend, inside it as undecided. Conversion crossing base is a short term signal, and a thick cloud is stronger support or resistance than a thin one. With so many lines it lags, and in ranges it says little.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Conversion line length | conversion | 9 | 1 to 5000 |
| Base line length | base | 26 | 1 to 5000 |
| Span B length | span_b | 52 | 1 to 5000 |
| Displacement | displacement | 26 | 1 to 500 |
Lines. conversion (Conversion), base (Base), span_a (Span A, drawn displacement bars ahead), span_b (Span B, drawn displacement bars ahead) and lagging (Lagging, drawn displacement bars back).
In a strategy. A strategy reads unshifted values: ctx.ind("ichimoku").span_a now is what the chart draws displacement bars ahead. To test price against the cloud under the current bar, keep the spans of the last displacement bars and use the oldest; .conversion over .base is a simple trigger.
The call with every input at its default:
pythonichimoku = ctx.ind("ichimoku", conversion=9, base=26, span_b=52, displacement=26)
ichimoku.conversion, ichimoku.base, ichimoku.span_a, ichimoku.span_b, ichimoku.laggingReference: Hosoda (Ichimoku Kinko Hyo).
Aroon
aroon, drawn in a pane of its own.
What it measures. Tushar Chande's Aroon: how many bars have passed since the highest high and since the lowest low, as two lines from 0 to 100.
Formula. Over a window of length + 1 bars, up is 100 times (length minus the bars since the highest high) divided by length, down the same for the lowest low. A new high gives 100, a high length bars ago 0; on a tie the most recent bar counts. The oscillator is up minus down. The first value is on bar length, counting from 0, as TA-Lib's AROON and AROONOSC.
How to read it. Up near 100 with down near 0 points to a fresh uptrend, the reverse to a downtrend. Both low means no new extremes, often a range. Up crossing down is an early sign of a trend change; 70 and 30 are the usual guides.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 14 | 1 to 5000 |
Lines. up (Up), down (Down) and osc (Oscillator, read by a strategy, not drawn). Levels at 30 and 70. The value stays between 0 and 100.
In a strategy. Enter long when ctx.ind("aroon", length=14).up crosses above .down, or use .osc above 0 as a trend filter.
The call with every input at its default:
pythonaroon = ctx.ind("aroon", length=14)
aroon.up, aroon.down, aroon.oscReference: TA-Lib AROON, AROONOSC (Chande 1995).
Directional movement index (DMI)
dmi, drawn in a pane of its own.
What it measures. Welles Wilder's directional movement: +DI and -DI show which side moves more, the ADX how strong the trend is, whatever its direction.
Formula. +DM is the rise of the high when it beats the fall of the low, -DM the reverse, else 0. DM and true range are Wilder sums: the first length minus 1 added up, then S minus S / length plus the new value. The DIs are 100 times DM / TR, DX is 100 times |+DI minus -DI| / (+DI plus -DI), the ADX the mean of the first smooth DX values, then Wilder's average. All start on bar length + smooth minus 1; with smooth equal to length this is TA-Lib's ADX.
How to read it. An ADX above 25 is usually read as a trending market, below 20 as a range; a rising ADX means the trend gets stronger, not that price rises. +DI above -DI points up, below points down. Without an ADX filter the DI crosses give many false signals.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| DI length | length | 14 | 2 to 5000 |
| ADX smoothing | smooth | 14 | 1 to 5000 |
Lines. adx (ADX), plus (+DI) and minus (-DI). A level at 25. The value stays between 0 and 100.
In a strategy. Trade +DI over -DI only while the trend is strong: ctx.ind("dmi", length=14, smooth=14).adx above 25 and .plus above .minus.
The call with every input at its default:
pythondmi = ctx.ind("dmi", length=14, smooth=14)
dmi.adx, dmi.plus, dmi.minusReference: TA-Lib ADX, PLUS_DI, MINUS_DI (Wilder 1978).
Linear regression (LinReg)
linreg, drawn on the price.
What it measures. The end point of the straight line that fits the last bars best, a moving average that follows the trend with little lag.
Formula. A least squares line is fitted through the source over the last length bars, x running from 0 for the oldest bar, and the value is that line at the newest bar. The first value comes once length bars are in, as TA-Lib's LINEARREG. A window of equal prices gives a flat line at that price.
How to read it. It follows price more closely than an SMA of the same length because it carries the fitted trend to the current bar, and overshoots at turns. A rising line means the fitted trend points up; the gap between price and line shows how far price strays from it.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 2 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. linreg (LinReg).
In a strategy. A smooth trend line, ctx.ind("linreg", length=20), or the close minus it as a stretch measure: fade large gaps in a range, follow the line's direction in a trend.
The call with every input at its default:
pythonctx.ind("linreg", length=20, source="close")Reference: TA-Lib LINEARREG.
Vortex indicator (VI)
vortex, drawn in a pane of its own.
What it measures. Botes and Siepman's vortex indicator: two lines that compare upward with downward price movement to catch the start of a trend.
Formula. VI+ is the sum of |high minus previous low| over length bars divided by the sum of the true range over the same bars; VI- uses |low minus previous high|. The first bar has no previous bar, so the first value is on bar length, counting from 0. While the true range sums to 0, with no movement at all, both lines have no value.
How to read it. VI+ above VI- points to an uptrend, below it to a downtrend, and the cross is the signal. Both lines swing around 1. In sideways markets they cross often, so a trend filter or a second confirmation helps.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 14 | 1 to 5000 |
Lines. plus (VI+) and minus (VI-). A level at 1.
In a strategy. Enter long when ctx.ind("vortex", length=14).plus crosses above .minus, exit on the opposite cross.
The call with every input at its default:
pythonvortex = ctx.ind("vortex", length=14)
vortex.plus, vortex.minusReference: Botes and Siepman 2010.
Heikin Ashi (HA)
heikin_ashi, drawn on the price.
What it measures. Heikin Ashi candles, averaged candles that smooth the bars so a trend reads as a run of one colour, with their direction and how long the run has lasted.
Formula. HA close = (open plus high plus low plus close) divided by 4. HA open = (previous HA open plus previous HA close) divided by 2, on the first bar (open plus close) divided by 2. HA high is the highest and HA low the lowest of the bar's extreme, HA open and HA close. direction is +1 when HA close is above HA open, -1 below, 0 equal; run counts the candles in a row of one direction.
How to read it. A run of rising candles without a lower wick is a strong up move, a small candle with wicks on both sides a pause. The values are averages, not prices that traded: an order fills at the real price, never at HA close. The first bar's seed fades by half with every bar, below 0.1 percent after ten.
No inputs.
Lines. ha_close (HA close), ha_open (HA open), ha_high (HA high, read by a strategy, not drawn), ha_low (HA low, read by a strategy, not drawn), direction (Direction, read by a strategy, not drawn), run (Run, read by a strategy, not drawn) and no_opposite_wick (No opposite wick, read by a strategy, not drawn).
In a strategy. Following the colour: with ha = ctx.ind("heikin_ashi") go long when ha.direction turns +1 with ha.no_opposite_wick at 1, and exit once ha.direction turns -1, or wait for ha.run of 3.
The call with every input at its default:
pythonheikin_ashi = ctx.ind("heikin_ashi")
heikin_ashi.ha_close, heikin_ashi.ha_open, heikin_ashi.ha_high, heikin_ashi.ha_low, heikin_ashi.direction, heikin_ashi.run, heikin_ashi.no_opposite_wickReference: Valcu 2004, Technical Analysis of Stocks and Commodities.
Renko bricks
renko, drawn on the price.
What it measures. Renko bricks: a brick of fixed size each time the close has moved that far, ignoring time, so only moves of at least one brick show.
Formula. The size is the fixed size, or ATR(atr_length) times atr_mult taken once, at the first bar with an ATR above zero. That bar's close is the anchor; brick edges sit on anchor plus k times size. A brick in the same direction needs a close one size beyond the last brick's close, a reversal two sizes, that is one beyond its open. A close within 0.0000001 of a brick of an edge counts as on it.
How to read it. The bricks come from closes only, and a brick is final at the close of the bar that made it: one bar can add several. direction is +1 or -1 for the last brick, run counts bricks in a row, reversal is 1 on a bar that turned. A fixed size is in price units, so it must suit the instrument: 0.001 is 10 pips on EURUSD.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Brick size | mode | "atr" | atr (ATR), fixed (Fixed) |
| Fixed size (price) | size | 0.001 | 1e-05 to 100000.0 |
| ATR length | atr_length | 14 | 1 to 500 |
| ATR multiple | atr_mult | 1.0 | 0.01 to 50.0 |
Lines. brick_close (Brick close), brick_open (Brick open), direction (Direction, read by a strategy, not drawn), new_bricks (New bricks, read by a strategy, not drawn), run (Run, read by a strategy, not drawn), reversal (Reversal, read by a strategy, not drawn) and size (Brick size, read by a strategy, not drawn).
In a strategy. Trading the turns: with r = ctx.ind("renko", mode="atr", atr_length=14, atr_mult=1.0) go long when r.reversal is 1 and r.direction is +1, short when it is -1, the stop at r.brick_open minus one r.size.
The call with every input at its default:
pythonrenko = ctx.ind("renko", mode="atr", size=0.001, atr_length=14, atr_mult=1.0)
renko.brick_close, renko.brick_open, renko.direction, renko.new_bricks, renko.run, renko.reversal, renko.sizeReference: Renko from closes with a two brick reversal (Nison 1994).
Momentum
Relative strength index (RSI)
rsi, drawn in a pane of its own.
What it measures. How strongly the recent closes rose against how strongly they fell, on a scale from 0 to 100.
Formula. Each bar's rise and fall are averaged with Wilder's smoothing over the length, the first average being the plain mean of the first changes. RSI is 100 minus 100 divided by one plus the average rise over the average fall; with no falls at all it is 100.
How to read it. Above 70 the market is often called overbought, below 30 oversold. In a strong trend RSI can stay there for a long time, so a turn back across the line says more than the level itself.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 14 | 2 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. rsi (RSI). Levels at 30 and 70. The value stays between 0 and 100.
In a strategy. A mean reversion entry when RSI crosses back above 30: ctx.ind("rsi", length=14) read each bar and compared with the value a bar earlier, or as a filter that only allows longs while it is below 70.
The call with every input at its default:
pythonctx.ind("rsi", length=14, source="close")Reference: TA-Lib RSI (Wilder 1978).
Moving average convergence divergence (MACD)
macd, drawn in a pane of its own.
What it measures. The gap between a fast and a slow exponential average of price, with a signal line and a histogram, to show the direction of a trend and when it gains or loses pace.
Formula. The MACD line is EMA(fast) minus EMA(slow) of the source, the signal line an EMA of the MACD line over the signal length, the histogram MACD minus signal. Every EMA is seeded with the plain mean of its own first values, so the line is exactly the difference of the two ema lines. TA-Lib MACD seeds the fast average later so both start together; the values agree once that seed has decayed. After Appel 1979.
How to read it. Above zero the fast average is over the slow one, below zero under it. MACD crossing its signal line, or the histogram changing sign, marks a change of pace; divergences between price and MACD hint at a fading move. The values are in price units and cannot be compared across markets. In a sideways market the lines cross often and say little.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Fast length | fast | 12 | 1 to 5000 |
| Slow length | slow | 26 | 1 to 5000 |
| Signal length | signal | 9 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Lines. macd (MACD), signal (Signal) and hist (Histogram). A level at 0.
In a strategy. A trend entry when the MACD line crosses above its signal: ctx.ind("macd", fast=12, slow=26, signal=9) gives .macd, .signal and .hist; buy when .hist turns positive, often only while .macd is above zero.
The call with every input at its default:
pythonmacd = ctx.ind("macd", fast=12, slow=26, signal=9, source="close")
macd.macd, macd.signal, macd.histReference: TA-Lib MACD (Appel 1979).
Stochastic oscillator
stoch, drawn in a pane of its own.
What it measures. Where the close sits within the high to low range of the last bars, from 0 at the lowest low to 100 at the highest high.
Formula. The raw %K is 100 times the close minus the lowest low, divided by the highest high minus the lowest low, over the %K length. The %K line is an SMA of the raw %K over the %K smoothing, %D an SMA of %K over the %D length; a smoothing of 1 leaves the value raw. A range of zero gives a raw %K of 0. %K is held back until %D has a value, so both lines start on the same bar. As TA-Lib STOCH with SMA smoothing, after Lane.
How to read it. Above 80 the close is near the top of its recent range, below 20 near the bottom. In a trend the lines can stay at an extreme for a long time, so %K crossing %D, or a return across 80 or 20, says more than the level. Divergences between price and %K hint at a fading move. It reacts fast and gives many false turns in a choppy market.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| %K length | length | 14 | 1 to 5000 |
| %K smoothing | smooth_k | 3 | 1 to 5000 |
| %D length | smooth_d | 3 | 1 to 5000 |
Lines. k (%K) and d (%D). Levels at 20 and 80. The value stays between 0 and 100.
In a strategy. A mean reversion entry when %K crosses above %D below 20: ctx.ind("stoch", length=14, smooth_k=3, smooth_d=3) gives .k and .d; compare both with the previous bar, and take longs only in the direction of the trend on a higher timeframe.
The call with every input at its default:
pythonstoch = ctx.ind("stoch", length=14, smooth_k=3, smooth_d=3)
stoch.k, stoch.dReference: TA-Lib STOCH with SMA smoothing (Lane).
Stochastic RSI (StochRSI)
stochrsi, drawn in a pane of its own.
What it measures. Where the RSI sits within its own range of the last bars, from 0 at its lowest to 100 at its highest. It turns faster than the RSI itself.
Formula. First the catalogue's RSI over the RSI length, with Wilder's smoothing. The raw %K is 100 times the RSI minus its lowest value, divided by its highest minus its lowest, over the stochastic length; %K is an SMA of that over the %K smoothing, %D an SMA of %K. A range under 1e-9 RSI points counts as flat and gives 0. %K is held back until %D has a value. With a %K smoothing of 1 it is TA-Lib STOCHRSI, after Chande and Kroll 1994.
How to read it. Above 80 the RSI is at the top of its recent range, below 20 at the bottom. As a stochastic of an oscillator it reaches the extremes often and stays there in a trend, so it is noisier than RSI; crossings of %K and %D and returns across 20 or 80 matter more than the level. It shows where the RSI stands, not how strong the move is.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| RSI length | rsi_length | 14 | 2 to 5000 |
| Stochastic length | length | 14 | 1 to 5000 |
| %K smoothing | smooth_k | 3 | 1 to 5000 |
| %D length | smooth_d | 3 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Lines. k (%K) and d (%D). Levels at 20 and 80. The value stays between 0 and 100.
In a strategy. Timing inside a trend: in an uptrend, buy a pullback when ctx.ind("stochrsi", rsi_length=14, length=14).k crosses back above 20, compared with its value a bar earlier.
The call with every input at its default:
pythonstochrsi = ctx.ind("stochrsi", rsi_length=14, length=14, smooth_k=3, smooth_d=3, source="close")
stochrsi.k, stochrsi.dReference: TA-Lib STOCHRSI (Chande and Kroll 1994), %K smoothed by an SMA.
Commodity channel index (CCI)
cci, drawn in a pane of its own.
What it measures. How far the typical price is from its average, in units of its mean deviation, scaled so that most values fall between -100 and 100.
Formula. The typical price is (high + low + close) / 3. CCI is the typical price minus its SMA over the length, divided by 0.015 times the mean absolute deviation of the typical prices from that SMA. It is 0 when the price sits on its average, when the deviation is zero, and for a window of identical prices. As TA-Lib CCI, after Lambert 1980.
How to read it. Above 100 price is unusually high against its average, below -100 unusually low. It has no fixed bounds, so values of 200 or more occur in strong moves. Lambert took a rise above 100 as the start of a trend; others read the same levels as overbought and oversold. A zero crossing shows price passing its average.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 2 to 5000 |
Line. cci (CCI). Levels at -100 and 100.
In a strategy. A breakout entry when CCI rises above 100 and an exit when it falls back below: ctx.ind("cci", length=20) compared with its value a bar earlier.
The call with every input at its default:
pythonctx.ind("cci", length=20)Reference: TA-Lib CCI (Lambert 1980).
Rate of change (ROC)
roc, drawn in a pane of its own.
What it measures. How much price has changed over the last bars, in percent.
Formula. ROC is (price divided by the price length bars ago, minus 1) times 100, on the chosen source, with no smoothing. It is 0 when the earlier price is 0. As TA-Lib ROC.
How to read it. Above zero price is higher than at the start of the window, below zero lower. The further from zero, the faster the move; a ROC that sinks toward zero while price still rises shows the move slowing. Each value rests on a single old bar, so one unusual bar at the start of the window moves it. Being in percent, it compares markets at different price levels.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 10 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. roc (ROC). A level at 0.
In a strategy. A momentum filter that allows longs only while price rose over the window: ctx.ind("roc", length=10) > 0, with an exit when it falls back below zero.
The call with every input at its default:
pythonctx.ind("roc", length=10, source="close")Reference: TA-Lib ROC.
Momentum (MOM)
mom, drawn in a pane of its own.
What it measures. How far price has moved over the last bars, in price units.
Formula. Momentum is the price minus the price length bars ago, on the chosen source, with no smoothing. As TA-Lib MOM.
How to read it. Above zero price is higher than at the start of the window, below zero lower; the distance from zero is the size of the move. In price units, so values cannot be compared between markets or across years with very different prices; ROC does that in percent. A momentum that falls while price still rises shows the move slowing.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 10 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. mom (Momentum). A level at 0.
In a strategy. A simple trend filter: ctx.ind("mom", length=10) > 0 allows longs only while price is above where it was ten bars ago, with an exit when it turns negative.
The call with every input at its default:
pythonctx.ind("mom", length=10, source="close")Reference: TA-Lib MOM.
Williams %R
willr, drawn in a pane of its own.
What it measures. Where the close sits within the high to low range of the last bars, on a scale from 0 at the highest high to -100 at the lowest low.
Formula. %R is -100 times the highest high minus the close, divided by the highest high minus the lowest low, over the length. That is the raw stochastic %K moved down by 100, with no smoothing. A range of zero gives 0. As TA-Lib WILLR, after Williams 1973.
How to read it. Above -20 the close is near the top of its range, often called overbought; below -80 near the bottom, oversold. In a trend it can stay there for a long time, so a move back across -20 or -80 says more than the level. Without smoothing it is jumpy.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 14 | 2 to 5000 |
Line. willr (%R). Levels at -80 and -20. The value stays between -100 and 0.
In a strategy. A pullback entry in an uptrend when %R falls below -80 and turns back up: ctx.ind("willr", length=14) compared with its value a bar earlier.
The call with every input at its default:
pythonctx.ind("willr", length=14)Reference: TA-Lib WILLR (Williams 1973).
True strength index (TSI)
tsi, drawn in a pane of its own.
What it measures. The smoothed bar to bar price change against the smoothed size of those changes, from -100 to 100: the direction of momentum and how steady it is.
Formula. The change m is the price minus the previous price. TSI is 100 times an EMA over the short length of an EMA over the long length of m, divided by the same double EMA of the absolute m. The signal line is an EMA of TSI over the signal length. Every EMA is seeded with the plain mean of its own first values. There is no value while the smoothed absolute change is zero, which only happens before price first moves. After Blau 1991.
How to read it. Above zero the smoothed changes are mostly up, below zero mostly down; values near 100 or -100 mean nearly every bar moved the same way. Crossings of zero and of the signal line mark turns. The double smoothing makes it calmer than RSI but also later. Divergences with price hint at a fading trend.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Long length | long | 25 | 1 to 5000 |
| Short length | short | 13 | 1 to 5000 |
| Signal length | signal | 13 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Lines. tsi (TSI) and signal (Signal). A level at 0.
In a strategy. A trend entry when TSI crosses above its signal line while above zero: ctx.ind("tsi", long=25, short=13, signal=13) gives .tsi and .signal, each compared with the previous bar.
The call with every input at its default:
pythontsi = ctx.ind("tsi", long=25, short=13, signal=13, source="close")
tsi.tsi, tsi.signalReference: Blau 1991.
Ultimate oscillator (UO)
uo, drawn in a pane of its own.
What it measures. Buying pressure against the true range over three lengths at once, weighted toward the shortest, on a scale from 0 to 100.
Formula. Buying pressure is the close minus the lower of the low and the previous close; the true range is the bar's range widened by any gap to the previous close. Both are summed over each of the three lengths, sorted from short to long, and the ratios weighted 4, 2 and 1. UO is 100 times the weighted sum divided by 7; a length whose range sum is zero adds nothing while the divisor stays 7. The first bar is not used. As TA-Lib ULTOSC, after Williams 1985.
How to read it. Above 70 buying pressure dominated across the three lengths, below 30 selling pressure. Williams' own signal was a bullish divergence with the oscillator below 30, then the oscillator rising above the high it made between the two lows; a plain cross of 30 or 70 says less. With three lengths in one it is steadier than a single length oscillator but reaches the extremes less often.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Short length | fast | 7 | 1 to 5000 |
| Medium length | mid | 14 | 1 to 5000 |
| Long length | slow | 28 | 1 to 5000 |
Line. uo (UO). Levels at 30 and 70. The value stays between 0 and 100.
In a strategy. A filter that allows longs only while buying pressure leads: ctx.ind("uo", fast=7, mid=14, slow=28) > 50, or an exit from a long once it rises above 70 and turns down.
The call with every input at its default:
pythonctx.ind("uo", fast=7, mid=14, slow=28)Reference: TA-Lib ULTOSC (Williams 1985).
Awesome oscillator (AO)
ao, drawn in a pane of its own.
What it measures. The gap between a short and a long simple average of the bar midpoints: whether recent momentum is stronger or weaker than the longer term one.
Formula. The midpoint of each bar is (high + low) / 2. AO is the SMA of the midpoints over the fast length minus their SMA over the slow length, drawn as a histogram. Nothing else is smoothed. After Bill Williams, Trading Chaos, 1995.
How to read it. Above zero the short average is over the long one, below zero under it. Williams read a zero crossing, a saucer (two falling bars, then a rising one, on the same side of zero) and two peaks on the same side as signals. The values are in price units and not comparable between markets. Like any crossing of averages it lags and whipsaws in a sideways market.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Fast length | fast | 5 | 1 to 5000 |
| Slow length | slow | 34 | 1 to 5000 |
Line. ao (AO). A level at 0.
In a strategy. A momentum entry when AO crosses above zero: ctx.ind("ao", fast=5, slow=34) compared with its value a bar earlier, with the opposite crossing as the exit.
The call with every input at its default:
pythonctx.ind("ao", fast=5, slow=34)Reference: Williams 1995, Trading Chaos.
Chande momentum oscillator (CMO)
cmo, drawn in a pane of its own.
What it measures. The balance of up moves against down moves over the last bars, from -100 when every change was down to 100 when every change was up.
Formula. Over the last length changes of the source, up is the sum of the rises and down the sum of the falls. CMO is 100 times (up minus down) divided by (up plus down), and 0 when nothing moved. This is Chande's original form with plain sums (Chande and Kroll 1994): no smoothing, and a change drops out after length bars. TA-Lib's CMO is not this one: it smooths the moves the Wilder way, as RSI does, which makes it 2 times RSI minus 100.
How to read it. Above 50 the rises clearly outweigh the falls, below -50 the reverse; Chande read these as overbought and oversold. Zero means balance. With plain sums it reacts at once to a large change and again when that change leaves the window, so it is jumpier than RSI. Divergences with price hint at a fading move.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 9 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. cmo (CMO). Levels at -50 and 50. The value stays between -100 and 100.
In a strategy. A mean reversion entry when CMO rises back above -50: ctx.ind("cmo", length=9) compared with its value a bar earlier, or a trend filter that allows longs only while it is above zero.
The call with every input at its default:
pythonctx.ind("cmo", length=9, source="close")Reference: Chande and Kroll 1994, The New Technical Trader.
Percentage price oscillator (PPO)
ppo, drawn in a pane of its own.
What it measures. The gap between a fast and a slow exponential average as a percentage of the slow one: MACD in percent, so it can be compared across markets and price levels.
Formula. PPO is (EMA(fast) minus EMA(slow)) divided by EMA(slow), times 100, and 0 when the slow average is 0. The signal line is an EMA of PPO over the signal length, the histogram PPO minus signal. Every EMA is seeded with the plain mean of its own first values. TA-Lib PPO seeds the fast average later; the values agree once that seed has decayed. After Appel.
How to read it. Above zero the fast average is over the slow one, by that many percent. A crossing of the signal line or a histogram changing sign marks a change of pace; divergences hint at a fading move. Read it like MACD, but in percent: 2 means the same on a stock at 10 as on one at 1000. It lags and crosses often in a sideways market.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Fast length | fast | 12 | 1 to 5000 |
| Slow length | slow | 26 | 1 to 5000 |
| Signal length | signal | 9 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Lines. ppo (PPO), signal (Signal) and hist (Histogram). A level at 0.
In a strategy. A trend entry when the histogram turns positive: ctx.ind("ppo", fast=12, slow=26, signal=9) gives .ppo, .signal and .hist, compared with the previous bar; or a filter that allows longs only while .ppo is above zero.
The call with every input at its default:
pythonppo = ctx.ind("ppo", fast=12, slow=26, signal=9, source="close")
ppo.ppo, ppo.signal, ppo.histReference: TA-Lib PPO with EMA (Appel).
TRIX
trix, drawn in a pane of its own.
What it measures. The bar to bar change of a triple smoothed exponential average, in percent: the slope of the trend with most short term noise removed.
Formula. Three EMAs over the same length are chained: the second averages the first, the third the second, each seeded with the plain mean of its own first values. TRIX is the percent change of the third average from the bar before, (now divided by before, minus 1) times 100, and 0 when the earlier value is 0. The first value is on bar 3 times (length minus 1) plus 1, counted from 0. As TA-Lib TRIX, after Hutson 1983.
How to read it. Above zero the smoothed trend rises, below zero it falls; a zero crossing marks a turn of the triple average. The heavy smoothing filters small swings but makes it late: it confirms a turn rather than anticipating it. The values are small, often a fraction of a percent, and depend on the timeframe.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 18 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. trix (TRIX). A level at 0.
In a strategy. A trend filter that allows longs only while ctx.ind("trix", length=18) > 0, or an entry when it crosses above zero, compared with its value a bar earlier.
The call with every input at its default:
pythonctx.ind("trix", length=18, source="close")Reference: TA-Lib TRIX (Hutson 1983).
Absolute price oscillator (APO)
apo, drawn in a pane of its own.
What it measures. The gap between a fast and a slow exponential average of price, in price units: the MACD line without its signal.
Formula. APO is EMA(fast) minus EMA(slow) of the source. Each EMA is seeded with the plain mean of its own first values, so APO equals the macd line with the same lengths, value for value. TA-Lib APO seeds the fast average later so both start on the same bar; the values agree once that seed has decayed.
How to read it. Above zero the fast average is over the slow one and the short term trend points up; below zero it points down. A zero crossing is the crossing of the two averages. In price units, so not comparable between markets; PPO is for that. It lags and whipsaws in a sideways market.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Fast length | fast | 12 | 1 to 5000 |
| Slow length | slow | 26 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. apo (APO). A level at 0.
In a strategy. A crossing of two averages as one number: when ctx.ind("apo", fast=12, slow=26) turns from below zero to above, the fast EMA has crossed over the slow one, a common trend entry.
The call with every input at its default:
pythonctx.ind("apo", fast=12, slow=26, source="close")Reference: TA-Lib APO with EMA.
Balance of power (BOP)
bop, drawn in a pane of its own.
What it measures. How far each bar closed from its open, against its full range, averaged over the last bars: whether buyers or sellers controlled the bars.
Formula. Each bar's raw value is (close minus open) divided by (high minus low), from -1 to 1; it is 0 on a bar with no range. The line is an SMA of the raw values over the smoothing length; a smoothing of 1 is the raw value itself, which is TA-Lib BOP. After Livshin 2001.
How to read it. Above zero the bars mostly closed above their open, below zero below it; near 1 or -1 they closed at their extremes. A turn of the smoothed line, or a divergence from price, can show control changing sides. Gaps between bars do not count, since only each bar's own open and close are used.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Smoothing | smooth | 14 | 1 to 5000 |
Line. bop (BOP). A level at 0. The value stays between -1 and 1.
In a strategy. A filter that allows longs only while buyers control the bars: ctx.ind("bop", smooth=14) > 0, or a confirmation of a breakout when it turns positive.
The call with every input at its default:
pythonctx.ind("bop", smooth=14)Reference: TA-Lib BOP (Livshin 2001), smoothed by an SMA.
Detrended price oscillator (DPO)
dpo, drawn in a pane of its own.
What it measures. How far price stands above or below its moving average with the trend taken out, to show the shorter cycles and their length.
Formula. This is the causal form, with n the length: the price n // 2 + 1 bars ago minus the SMA of the last n prices, written on the current bar. The textbook DPO pairs the same price and average but draws the value half a window back, which needs bars that come later. Here no value depends on a later bar; the line is the textbook one moved n // 2 + 1 bars to the right.
How to read it. Above zero the price of half a window ago stood above the average, below zero under it. Its peaks and troughs show the cycle, and the distance between them estimates its length. It is built to remove the trend, so it says nothing about trend direction, and each value describes the market half a window ago, not now.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 21 | 2 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. dpo (DPO). A level at 0.
In a strategy. Cycle timing for swing trades in a market without a strong trend: ctx.ind("dpo", length=21) read each bar, entering after it turns up from a trough. Each trough shows up length // 2 + 1 bars late, so measure the cycle first and allow for that delay.
The call with every input at its default:
pythonctx.ind("dpo", length=21, source="close")Reference: Detrended price oscillator, causal form.
Coppock curve
coppock, drawn in a pane of its own.
What it measures. A smoothed sum of two long rates of change, made by Coppock to spot the end of bear markets on monthly charts of a stock index.
Formula. Two rates of change in percent over the long and the short ROC length, each (price divided by the earlier price, minus 1) times 100 and 0 on an earlier price of 0, are added. The curve is a weighted moving average of that sum over the WMA length, the newest value weighing the length and the oldest 1. Coppock 1962 used monthly closes with 14 and 11 months and a WMA over 10.
How to read it. Coppock's buy signal was the curve turning up while below zero; he defined no sell signal. Above zero the two rates of change are positive on balance. On short bars it becomes an ordinary smoothed momentum line with many turns, and the long lengths make it late by design.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| WMA length | length | 10 | 1 to 5000 |
| Long ROC length | long | 14 | 1 to 5000 |
| Short ROC length | short | 11 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. coppock (Coppock). A level at 0.
In a strategy. A long term entry filter on monthly or weekly bars: buy when ctx.ind("coppock", length=10, long=14, short=11) is below zero and higher than a bar earlier.
The call with every input at its default:
pythonctx.ind("coppock", length=10, long=14, short=11, source="close")Reference: Coppock 1962, Barron's.
Volatility
Average true range (ATR)
atr, drawn in a pane of its own.
What it measures. How far price typically moves in one bar, gaps from the previous close included, averaged over the length. It is in price units, so it grows and shrinks with the market's own swings.
Formula. Each bar's true range is the largest of high minus low and the distances from the previous close to the high and to the low. The first bar has no previous close and is skipped. The first ATR is the plain mean of the first true ranges over the length, then Wilder's smoothing: the previous ATR times length minus one, plus the new true range, divided by the length. As TA-Lib ATR, after Wilder 1978.
How to read it. A rising ATR means wider bars and a more nervous market, a falling one a quieter market. It says nothing about direction. Because it is in price units it cannot be compared across markets or over long stretches of history; NATR is made for that.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 14 | 1 to 5000 |
Line. atr (ATR).
In a strategy. Stops and position sizes that follow volatility: a stop two ATRs below the entry, that is ctx.ind("atr", length=14) times 2, or a size that risks the same amount whatever the market's range.
The call with every input at its default:
pythonctx.ind("atr", length=14)Reference: TA-Lib ATR (Wilder 1978).
Bollinger Bands (BB)
bb, drawn on the price.
What it measures. A moving average with a band above and below it whose width follows the price's standard deviation, so the bands widen when price swings and narrow when it calms down.
Formula. The middle band is the simple moving average of the source over the length. The upper and lower bands are the middle plus and minus mult times the population standard deviation of the same prices (dividing by n, not n minus 1). The first value comes once the length is filled. As TA-Lib BBANDS, after Bollinger 1983.
How to read it. A close outside a band shows a strong move, not by itself a reversal; in a trend price can ride along the upper or lower band. Narrow bands (a squeeze) often come before a larger move without telling its direction. The middle band serves as a trend reference.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 2 to 5000 |
| Multiplier | mult | 2.0 | 0.1 to 10.0 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Lines. upper (Upper), middle (Basis) and lower (Lower).
In a strategy. Mean reversion back toward the middle after a close below the lower band, or a breakout entry when price closes above ctx.ind("bb", length=20, mult=2.0).upper after a squeeze.
The call with every input at its default:
pythonbb = ctx.ind("bb", length=20, mult=2.0, source="close")
bb.upper, bb.middle, bb.lowerReference: TA-Lib BBANDS (Bollinger 1983).
Normalized average true range (NATR)
natr, drawn in a pane of its own.
What it measures. The average true range as a percentage of the close, so the typical bar size can be compared across markets and price levels.
Formula. The catalogue's ATR (Wilder's smoothing of the true range, seeded with the mean of the first true ranges) divided by the bar's close and multiplied by 100. A close of 0 gives 0, as TA-Lib NATR returns for it. The first value comes on the same bar as the ATR's.
How to read it. A NATR of 1.5 means the average bar spans about one and a half percent of the price. Higher values mean a more volatile market. Like ATR it shows no direction, only how much price moves.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 14 | 1 to 5000 |
Line. natr (NATR).
In a strategy. Filter markets or phases by volatility, for example only trade while ctx.ind("natr", length=14) is between 0.5 and 3, or compare the volatility of the symbols in a portfolio.
The call with every input at its default:
pythonctx.ind("natr", length=14)Reference: TA-Lib NATR.
True range (TR)
tr, drawn in a pane of its own.
What it measures. The full range of a single bar, including any gap from the previous close. It is the raw building block of ATR.
Formula. The largest of three distances: high minus low, the high's distance from the previous close and the low's distance from the previous close. The first bar has no previous close and so no value, as in TA-Lib TRANGE (Wilder 1978). There is no length and no smoothing.
How to read it. A single tall bar stands out at once, which makes the line jumpy. Spikes mark news, opening gaps or panic. On its own it is noisy; most strategies average it, which is what ATR does.
No inputs.
Line. tr (TR).
In a strategy. Spot an unusually wide bar, for example one whose ctx.ind("tr") is more than twice the ATR, as a breakout or exhaustion signal, or use it as the input of a custom average.
The call with every input at its default:
pythonctx.ind("tr")Reference: TA-Lib TRANGE (Wilder 1978).
Bollinger %B
bbp, drawn in a pane of its own.
What it measures. Where the price sits within the Bollinger Bands: 0 at the lower band, 1 at the upper band, 0.5 at the middle. Below 0 or above 1 the price is outside the bands.
Formula. The price minus the lower band, divided by the upper band minus the lower band. The bands are the catalogue's Bollinger Bands with the same length, mult and source (SMA plus and minus mult population standard deviations). When every price in the window is the same the bands have no width and %B has no value. After Bollinger 2001.
How to read it. Above 1 the price is above the upper band, below 0 under the lower one. Readings that stay near 1 in an uptrend show strength rather than a top. Comparing %B highs with price highs can show a divergence: price makes a new high, %B does not.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 2 to 5000 |
| Multiplier | mult | 2.0 | 0.1 to 10.0 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. bbp (%B). Levels at 0 and 1.
In a strategy. A rule that does not depend on the price level: buy when ctx.ind("bbp", length=20) rises back above 0 after closing below it, or take profits when it reaches 1.
The call with every input at its default:
pythonctx.ind("bbp", length=20, mult=2.0, source="close")Reference: Bollinger 2001, bands as TA-Lib BBANDS.
Bollinger BandWidth (BBW)
bbw, drawn in a pane of its own.
What it measures. How wide the Bollinger Bands are relative to their middle band. It turns the squeeze, the narrowing of the bands, into one number.
Formula. The upper band minus the lower band, divided by the middle band, as a ratio and not a percentage. The bands are the catalogue's Bollinger Bands with the same length, mult and source, so with mult 2 it is four population standard deviations divided by the moving average. A middle band of 0 gives no value. After Bollinger 2001.
How to read it. Low values mean quiet, tight bands; a reading at its lowest in months marks a squeeze that often comes before a larger move. High values follow strong moves and tend to fall back. BandWidth shows nothing about direction.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 2 to 5000 |
| Multiplier | mult | 2.0 | 0.1 to 10.0 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. bbw (BandWidth).
In a strategy. A squeeze filter: take breakout entries only while ctx.ind("bbw", length=20) is near its lowest level of the last 120 bars, and leave the direction to another rule.
The call with every input at its default:
pythonctx.ind("bbw", length=20, mult=2.0, source="close")Reference: Bollinger 2001, bands as TA-Lib BBANDS.
Keltner Channels (KC)
kc, drawn on the price.
What it measures. A channel around an exponential moving average whose width is a multiple of the average true range. It follows volatility like Bollinger Bands, but more calmly, since ATR reacts less to single closes than a standard deviation.
Formula. The middle line is the EMA of the source over the length, seeded with the simple mean of the first values. The upper and lower lines are the middle plus and minus mult times the ATR over atr_length (Wilder's smoothing of the true range, the catalogue's ATR). All three lines start together on the first bar both averages have a value. Keltner 1960, in the ATR version after Raschke.
How to read it. A close outside the channel shows a strong move in that direction; in a trend the middle line often acts as support or resistance on pullbacks. When the Bollinger Bands lie inside the Keltner channel, volatility is unusually low, a common definition of a squeeze.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 2 to 5000 |
| Multiplier | mult | 2.0 | 0.1 to 10.0 |
| ATR length | atr_length | 10 | 1 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Lines. upper (Upper), middle (Basis) and lower (Lower).
In a strategy. A trend entry when the close breaks above ctx.ind("kc", length=20, mult=2.0).upper, with the middle line as a trailing exit, or a pullback buy near the middle line while the trend is up.
The call with every input at its default:
pythonkc = ctx.ind("kc", length=20, mult=2.0, atr_length=10, source="close")
kc.upper, kc.middle, kc.lowerReference: Keltner 1960, ATR version after Raschke (TA-Lib EMA and ATR).
Donchian Channels (DC)
dc, drawn on the price.
What it measures. The highest high and the lowest low of the last bars, with their midpoint. The channel shows the range the market has traded in over the length.
Formula. The upper line is the highest high and the lower line the lowest low of the last length bars, the current bar included. The middle line is their average. There is no smoothing; the first value comes once the length is filled. After Richard Donchian, with TA-Lib MAX and MIN.
How to read it. A rising upper line means price made a new high for the period, the classic breakout. The lines stay flat while nothing new happens and jump when an old extreme leaves the window. Since the current bar is in the window, its high can never lie above its own upper line.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 1 to 5000 |
Lines. upper (Upper), middle (Middle) and lower (Lower).
In a strategy. A breakout system in the style of the Turtles: buy when the high exceeds the upper line of the bar before, ctx.ind("dc", length=20).upper read one bar earlier, and exit on the lower line of a shorter channel.
The call with every input at its default:
pythondc = ctx.ind("dc", length=20)
dc.upper, dc.middle, dc.lowerReference: Donchian channels (TA-Lib MAX and MIN).
Standard deviation (StdDev)
stddev, drawn in a pane of its own.
What it measures. How widely the price spreads around its own average over the length, in price units. It is the volatility measure inside Bollinger Bands.
Formula. The population standard deviation of the source over the last length bars: the mean first, then the square root of the average squared distance from it, dividing by n and not n minus 1. It is computed in two passes, so a flat window can give a rounding residue near 1e-16 rather than exactly 0. As TA-Lib STDDEV with nbdev 1.
How to read it. Rising values mean price is straying further from its average, falling values a calmer market. Like ATR it is in price units and shows no direction. It reads one price per bar, so with the default close a bar's high and low play no part.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 2 to 5000 |
| Source | source | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
Line. stddev (StdDev).
In a strategy. Derive distances or sizes from volatility, for example a stop 1.5 times ctx.ind("stddev", length=20) away from the entry, or a filter that skips trades while it is below its own average.
The call with every input at its default:
pythonctx.ind("stddev", length=20, source="close")Reference: TA-Lib STDDEV.
Chaikin volatility (CHV)
chv, drawn in a pane of its own.
What it measures. How fast the average bar range is growing or shrinking, as a percentage change. It shows volatility expanding or contracting, not how large it is.
Formula. First an EMA of high minus low over the length, seeded with the simple mean of the first ranges. Chaikin volatility is the percentage change of that EMA against its value roc bars earlier: the difference divided by the earlier value, times 100. If the earlier EMA is 0, after only flat bars, there is no value. After Marc Chaikin.
How to read it. Above 0 the bars are wider than roc bars ago, below 0 narrower. Chaikin read a sharp rise in a short time as fear near bottoms and a slow decline over a long time as typical of mature tops; that is a tendency, not a rule. Gaps between bars do not count, only high minus low.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 10 | 2 to 5000 |
| ROC length | roc | 10 | 1 to 5000 |
Line. chv (CHV). A level at 0.
In a strategy. Wait for expanding volatility before a breakout entry, for example require ctx.ind("chv", length=10, roc=10) above 0, or open no new trades while it falls sharply.
The call with every input at its default:
pythonctx.ind("chv", length=10, roc=10)Reference: Chaikin (rate of change of an EMA of high minus low).
Historical volatility (HV)
hv, drawn in a pane of its own.
What it measures. How much the closes have moved from bar to bar, as an annualised volatility in percent, the unit options traders quote.
Formula. Each bar's log return is the natural log of the close over the previous close. HV is the population standard deviation of the last length log returns, times the square root of annual (bars per year), times 100. A close of 0 or below, or a ratio too extreme for a float, has no return: the window starts over and the line comes back after length valid returns. Close to close volatility.
How to read it. An HV of 20 means the closes moved as if the yearly standard deviation were about 20 percent. Compare it with its own history or with implied volatility. annual must match the timeframe, 252 for daily stock bars or 365 for daily crypto bars; a wrong value scales the whole line.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 10 | 2 to 5000 |
| Bars per year | annual | 252 | 1 to 100000 |
Line. hv (HV).
In a strategy. Scale position size inversely to volatility, or trade only while ctx.ind("hv", length=20, annual=252) is below a level such as 40, so a strategy carries a similar risk in calm and wild markets.
The call with every input at its default:
pythonctx.ind("hv", length=10, annual=252)Reference: Close to close volatility (annualised population deviation of log returns).
Choppiness index (CHOP)
chop, drawn in a pane of its own.
What it measures. Whether the market is trending or moving sideways, on a scale from 0 to 100. High values mean choppy, sideways trade, low values a directional move. It says nothing about the direction itself.
Formula. The sum of the true ranges over the last length bars, divided by the highest high minus the lowest low of the same bars; the base 10 log of that ratio, divided by the base 10 log of the length, times 100. The first bar has no true range, so the first value comes one bar after the first full window. A window with no range has no value. After Dreiss 1993.
How to read it. Above 61.8 the market is often called choppy and a trend unlikely to hold, below 38.2 trending. Long stretches of high values are often followed by a breakout, low values by a pause. The two levels are Fibonacci numbers by convention, not a law.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 14 | 2 to 5000 |
Line. chop (CHOP). Levels at 38.2 and 61.8. The value stays between 0 and 100.
In a strategy. A regime filter: let a trend system trade only while ctx.ind("chop", length=14) is below 38.2, and a range system only while it is above 61.8.
The call with every input at its default:
pythonctx.ind("chop", length=14)Reference: Dreiss 1993.
Volume
On balance volume (OBV)
obv, drawn in a pane of its own, needs volume.
What it measures. Whether volume goes with rising or with falling closes: a running total that adds a bar's volume when the close rises and takes it off when the close falls.
Formula. As TA-Lib's OBV (Granville 1963): the line starts at the first bar's volume, not at zero. Each later bar adds its volume when the close is above the previous close, takes it off when the close is below, and leaves the line where it is when the close is unchanged. It has a value from the first bar.
How to read it. The level itself means nothing, since it depends on where the data starts; read its direction against price. A new price high that OBV does not confirm is a bearish divergence, the reverse a bullish one. On forex the volume is tick volume, the number of price changes, so OBV follows activity rather than traded size.
No inputs.
Line. obv (OBV).
In a strategy. As a trend filter: compare ctx.ind("obv") with its value some bars earlier and only take longs while it rises, or look for a new price high that comes with a lower OBV high.
The call with every input at its default:
pythonctx.ind("obv")Reference: TA-Lib OBV (Granville 1963).
Volume weighted average price (VWAP)
vwap, drawn on the price, needs volume, uses the bar's time.
What it measures. The average price paid since the start of the current day, week or month, each bar weighted by its volume.
Formula. The sum of price times volume divided by the sum of volume over the bars of the period so far; the price is the source, by default hlc3 (high plus low plus close, divided by 3). Both sums start afresh at the first bar of each new period. Days start at 17:00 New York (daylight saving included) or, as Day starts chooses, at 00:00 UTC; weeks start with Monday's day, months with the 1st. While the period has traded no volume there is no value, not the last period's.
How to read it. Price above VWAP means the period's buyers are on average in profit, below it at a loss; many traders treat it as fair value and watch pullbacks to it. Early in a period it rests on few bars and moves a lot. By default the day starts at 17:00 New York, where forex turns the day, so Sunday evening counts to Monday; 00:00 UTC is the other choice. On forex the weights are tick volume, the number of price changes, not traded size.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Source | source | "hlc3" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
| Anchor period | anchor | "day" | day (Day), week (Week), month (Month) |
| Day starts | session | "ny" | ny (17:00 New York), utc (00:00 UTC) |
Line. vwap (VWAP).
In a strategy. As an intraday bias: only take longs while the close is above ctx.ind("vwap", anchor="day") and shorts while it is below, or enter on a pullback to it in the direction of the day's move.
The call with every input at its default:
pythonctx.ind("vwap", source="hlc3", anchor="day", session="ny")Reference: Session anchored VWAP (Berkowitz, Logue and Noser 1988).
Accumulation/distribution line (A/D)
ad, drawn in a pane of its own, needs volume.
What it measures. Whether volume comes with closes near the high or near the low of each bar: a running total of buying and selling pressure.
Formula. As TA-Lib's AD (Chaikin): a bar's close location is ((close minus low) minus (high minus close)) divided by (high minus low), from minus 1 at the low to plus 1 at the high. The line adds close location times volume every bar, starting from zero, so it has a value from the first bar. A bar with no range adds nothing.
How to read it. As with OBV the level depends on where the data starts; read the slope. A rising line while price goes sideways or falls points to accumulation, a falling one to distribution. Unlike OBV it does not see gaps between bars, since only where the close sits in the bar's own range counts. On forex the volume is tick volume.
No inputs.
Line. ad (A/D).
In a strategy. As a confirmation: compare ctx.ind("ad") with its value some bars earlier and only follow a breakout when the line rises with it.
The call with every input at its default:
pythonctx.ind("ad")Reference: TA-Lib AD (Chaikin).
Chaikin oscillator (ADOSC)
adosc, drawn in a pane of its own, needs volume.
What it measures. The momentum of the accumulation/distribution line: whether buying or selling pressure is building up or fading.
Formula. As TA-Lib's ADOSC (Chaikin): the fast EMA of the A/D line minus its slow EMA, by default 3 and 10. Unlike the other EMAs in this catalogue both start from the first bar's A/D value instead of a simple average, which keeps every value equal to TA-Lib's. The first value is shown once the longer length has run, at bar max(fast, slow) minus 1.
How to read it. Above zero the A/D line is rising faster than its slow average, below zero it is falling. Crossings of zero and divergences against price are the usual signals. The scale is in volume units, so values cannot be compared across markets, and on forex the volume is tick volume.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Fast length | fast | 3 | 2 to 500 |
| Slow length | slow | 10 | 2 to 500 |
Line. adosc (ADOSC). A level at 0.
In a strategy. As a momentum trigger: go long when ctx.ind("adosc", fast=3, slow=10) crosses above zero, compared with the value a bar earlier, while price is above its long average.
The call with every input at its default:
pythonctx.ind("adosc", fast=3, slow=10)Reference: TA-Lib ADOSC (Chaikin).
Chaikin money flow (CMF)
cmf, drawn in a pane of its own, needs volume.
What it measures. The share of the volume of the last n bars that came with closes near the high rather than near the low, from minus 1 to plus 1.
Formula. A bar's money flow volume is its close location, ((close minus low) minus (high minus close)) divided by (high minus low), times its volume, and 0 on a bar with no range. CMF is the sum of money flow volume over the length divided by the sum of volume over the same bars (Chaikin). The first value is at bar length minus 1; a window that traded no volume has no value.
How to read it. Above zero the closes have leaned toward the highs on the volume traded, below zero toward the lows. The further from zero, the clearer the pressure; values close to zero say little. As a ratio it compares across markets better than the A/D line, though on forex the volume is tick volume.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 20 | 1 to 5000 |
Line. cmf (CMF). A level at 0.
In a strategy. As a filter: only take longs while ctx.ind("cmf", length=20) is above zero, or close a long when it turns negative.
The call with every input at its default:
pythonctx.ind("cmf", length=20)Reference: Chaikin money flow (Chaikin).
Money flow index (MFI)
mfi, drawn in a pane of its own, needs volume.
What it measures. A volume weighted RSI: how much money flowed on bars with a rising typical price against all the money that flowed, on a scale from 0 to 100.
Formula. As TA-Lib's MFI (Quong and Soudack 1989): money flow is the typical price (high plus low plus close, divided by 3) times volume, positive when the typical price rose against the bar before, negative when it fell, neither when it held. MFI is 100 times the positive flow over positive plus negative flow, each summed over the length; the first value is at bar length. A window with no flow at all gives 0, as TA-Lib does.
How to read it. Above 80 the market is often called overbought, below 20 oversold. Like RSI it can stay there in a strong trend, so a turn back across the line and divergences against price say more than the level. On forex the volume is tick volume, which weights busy bars more, not larger orders.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 14 | 2 to 5000 |
Line. mfi (MFI). Levels at 20 and 80. The value stays between 0 and 100.
In a strategy. A mean reversion entry when ctx.ind("mfi", length=14) crosses back above 20, compared with the value a bar earlier, or a filter that allows no longs above 80.
The call with every input at its default:
pythonctx.ind("mfi", length=14)Reference: TA-Lib MFI (Quong and Soudack 1989).
Elder force index (EFI)
efi, drawn in a pane of its own, needs volume.
What it measures. The force behind a move: the change of the close times the volume, smoothed, so a large move on heavy volume counts more than the same move on little volume.
Formula. A bar's force is (close minus previous close) times volume (Elder 1993). The line is an EMA of the force over the length, seeded with the plain mean of its first values like every EMA in this catalogue. The first force needs a previous close, so the first value is at bar length.
How to read it. Above zero buyers have the upper hand, below zero sellers. Elder used a short length of 2 to time entries and 13 for the trend. The scale is price change times volume, so it cannot be compared across markets; on forex the volume is tick volume.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 13 | 1 to 5000 |
Line. efi (EFI). A level at 0.
In a strategy. Buying a pullback in an uptrend: while ctx.ind("efi", length=13) is above zero, enter long when ctx.ind("efi", length=2) dips below zero.
The call with every input at its default:
pythonctx.ind("efi", length=13)Reference: Elder force index (Elder 1993).
Ease of movement (EOM)
eom, drawn in a pane of its own, needs volume.
What it measures. How easily price moves for the volume traded: a large move on little volume is easy, a small move on heavy volume is hard.
Formula. Per bar (Arms): the move of the midpoint, (high plus low) divided by 2 minus the previous bar's, times the bar's range, divided by volume over the divisor (default 10000). A bar with no range or no volume counts as 0, so gaps in the volume leave no hole in the average. The line is the simple average over the length; the first move needs a previous bar, so the first value is at bar length.
How to read it. Above zero price rises with ease, below zero it falls with ease; near zero it barely moves for the volume traded. The size depends on price, volume and divisor, which only changes the scale, so across markets only the sign and the shape compare. On forex the volume is tick volume.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Length | length | 14 | 1 to 5000 |
| Divisor | divisor | 10000.0 | 1.0 to 1000000000000.0 |
Line. eom (EOM). A level at 0.
In a strategy. As a trend filter: only take longs while ctx.ind("eom", length=14) is above zero, and close them when it crosses below.
The call with every input at its default:
pythonctx.ind("eom", length=14, divisor=10000.0)Reference: Ease of movement (Arms).
Volume oscillator (VO)
vo, drawn in a pane of its own, needs volume.
What it measures. Whether volume is picking up or drying up: how far a fast average of volume is above or below a slow one, in percent.
Formula. The fast EMA of volume minus the slow EMA, divided by the slow EMA, times 100; by default 5 and 10. Each EMA is seeded with the plain mean of its own first values, so the first value is at bar max(fast, slow) minus 1. While the slow average is 0 there is no value.
How to read it. Above zero recent volume is higher than usual, below zero lower. It says nothing about direction: a breakout with a rising VO has more participation behind it than one on fading volume. On forex the volume is tick volume, which still shows when the market is busy, for example at a session open.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Fast length | fast | 5 | 1 to 5000 |
| Slow length | slow | 10 | 1 to 5000 |
Line. vo (VO). A level at 0.
In a strategy. As a breakout filter: only trade a breakout while ctx.ind("vo", fast=5, slow=10) is above zero.
The call with every input at its default:
pythonctx.ind("vo", fast=5, slow=10)Reference: Volume oscillator, EMA based.
Price volume trend (PVT)
pvt, drawn in a pane of its own, needs volume.
What it measures. Like on balance volume, but each bar adds volume in proportion to the percentage change of the close, so small moves count little.
Formula. A running total that adds (close minus previous close) divided by the previous close, times volume, every bar. It starts at 0 on the first bar, which has no change, so it has a value from the first bar. A previous close of 0 adds nothing rather than dividing by it.
How to read it. The level depends on where the data starts; read the slope against price. A rising PVT confirms an uptrend, and a new price high without a new PVT high is a divergence. On forex the volume is tick volume.
No inputs.
Line. pvt (PVT).
In a strategy. As a trend filter: compare ctx.ind("pvt") with its value some bars earlier and only take longs while it rises.
The call with every input at its default:
pythonctx.ind("pvt")Reference: Price volume trend.
Levels
Pivot points (Pivots)
pivots, drawn on the price, uses the bar's time.
What it measures. Support and resistance levels for the current day, week or month, worked out from the high, low and close of the one before.
Formula. From the last completed period: P = (high plus low plus close) divided by 3. Classic: R1 = 2P minus low, S1 = 2P minus high, R2 and S2 = P plus or minus the range, R3 = high plus 2(P minus low), S3 = low minus 2(high minus P). Fibonacci: P plus or minus 0.382, 0.618 and 1 times the range. Camarilla (Scott 1989): close plus or minus 1.1 times the range divided by 12, 6, 4 and 2 for levels 1 to 4; only it has R4 and S4. Days start at 17:00 New York or, as Day starts chooses, at 00:00 UTC; weeks start with Monday's day, months with the 1st.
How to read it. The levels hold for the whole period and step at its first bar; nothing shows before the first period in the data has ended, and a period the data starts inside counts from its first bar. Price often reacts at P and the first levels. With the default 17:00 New York day a forex Sunday evening is the start of Monday, so Monday's daily levels are Friday's; with 00:00 UTC days they come from those few Sunday hours.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Type | kind | "classic" | classic (Classic), fibonacci (Fibonacci), camarilla (Camarilla) |
| Period | period | "day" | day (Day), week (Week), month (Month) |
| Day starts | session | "ny" | ny (17:00 New York), utc (00:00 UTC) |
Lines. p (P), r1 (R1), r2 (R2), r3 (R3), s1 (S1), s2 (S2), s3 (S3), r4 (R4) and s4 (S4).
In a strategy. As targets and stops: with ctx.ind("pivots", kind="classic", period="day") a long bought near .p takes .r1 as its target and a stop below .s1. Each level reads by its name: p, r1 to r3, s1 to s3, and r4 and s4 for Camarilla.
The call with every input at its default:
pythonpivots = ctx.ind("pivots", kind="classic", period="day", session="ny")
pivots.p, pivots.r1, pivots.r2, pivots.r3, pivots.s1, pivots.s2, pivots.s3, pivots.r4, pivots.s4Reference: Floor trader pivots; Fibonacci pivots; Camarilla (Scott 1989).
ZigZag
zigzag, drawn on the price.
What it measures. The swing highs and lows that a reversal of at least the set percentage has confirmed, drawn as a level that steps to each new swing.
Formula. Extremes are highs and lows, reversals are judged on the close. After a swing high the candidate low is the lowest low at least depth bars after it, confirmed by the first close at or above candidate times (1 plus deviation/100); lows mirror this. Before the first swing both sides are open and the first confirmed sets the direction. At most one swing per bar. The zigzag output is the price of the last confirmed swing, swing is +1 for a high and -1 for a low; no value before the first swing.
How to read it. A swing shows on the bar that confirms it, at the price of its extreme, and never moves afterwards. Most charting tools draw ZigZag from extreme to extreme and keep moving the last leg as price goes on, which looks cleaner in hindsight than anything a strategy could have traded. Here each swing arrives late, by the bars the reversal took, but a backtest only sees what was known at the time.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Deviation % | deviation | 5.0 | 0.01 to 100.0 |
| Depth (bars) | depth | 10 | 1 to 500 |
Lines. zigzag (ZigZag) and swing (Swing, read by a strategy, not drawn).
In a strategy. Reacting to a fresh swing: when ctx.ind("zigzag", deviation=5.0, depth=10).swing turns from +1 to -1 a low has just been confirmed, a long entry with its stop below .zigzag, the price of that low.
The call with every input at its default:
pythonzigzag = ctx.ind("zigzag", deviation=5.0, depth=10)
zigzag.zigzag, zigzag.swingReference: ZigZag by percent deviation, confirmed without repainting.
Market structure
Market structure (BoS/CHoCH)
structure, drawn on the price.
What it measures. The swing highs and lows, the trend they form and the bars where price breaks them: a break of structure (BoS) with the trend, a change of character (CHoCH) against it.
Formula. A swing high has a high above the length bars before it and not below the length bars after it; it is confirmed once those bars have closed. Lows mirror this. A close (or, with Break on wick, a high) above the last swing high breaks it, once. A break with the trend, or the first one, is a BoS (+1 up, -1 down); one against the trend is a CHoCH and turns the trend. One break per bar, the break up first.
How to read it. A swing shows length bars after its extreme, on the bar that confirms it, and never moves. trend is +1 after a break up, -1 after a break down and 0 before the first. bos and choch are +1 or -1 on the bar of the break and 0 otherwise; the level lines hold the price the last BoS and CHoCH broke.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Swing bars each side | length | 3 | 1 to 50 |
| Break on | break_on | "close" | close (Close), wick (Wick) |
Lines. trend (Trend, read by a strategy, not drawn), bos (BoS, read by a strategy, not drawn), choch (CHoCH, read by a strategy, not drawn), swing_high (Swing high), swing_low (Swing low), bos_level (BoS level) and choch_level (CHoCH level).
In a strategy. Trade with the structure: buy when ctx.ind("structure", length=3, break_on="close").choch is 1, the trend has just turned up, with the stop below .swing_low, and add on each later .bos of 1.
The call with every input at its default:
pythonstructure = ctx.ind("structure", length=3, break_on="close")
structure.trend, structure.bos, structure.choch, structure.swing_high, structure.swing_low, structure.bos_level, structure.choch_levelReference: ICT market structure, from public descriptions (#546).
Fair value gaps (FVG)
fvg, drawn on the price.
What it measures. Three bar price gaps: ranges price jumped over so fast that the first and the third candle do not overlap, which often act as support or resistance when price comes back.
Formula. Bullish when the third candle's low is above the first candle's high: the gap runs from that high to that low. Bearish when the third high is below the first low. It counts when at least min_size times the ATR (Wilder, atr_length) at the third candle high. From the next bar a bullish gap is filled when a low reaches its bottom, or its middle with Filled at 50 %; bearish gaps mirror this.
How to read it. The lines show the nearest open bullish gap (the highest) and the nearest bearish one (the lowest); None when there is none. The new and filled flags are 1 on the bar of the event. A gap shows on its third candle, never earlier, and at most max_zones per side are kept.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| ATR length | atr_length | 14 | 1 to 500 |
| Minimum size (ATR) | min_size | 0.25 | 0.0 to 10.0 |
| Filled at | fill | "full" | full (Full pass), half (50 % (consequent encroachment)) |
| Zones kept per side | max_zones | 20 | 1 to 500 |
Lines. bull_top (Bullish top), bull_bottom (Bullish bottom), bear_top (Bearish top), bear_bottom (Bearish bottom), bull_new (New bullish, read by a strategy, not drawn), bear_new (New bearish, read by a strategy, not drawn), bull_filled (Bullish filled, read by a strategy, not drawn) and bear_filled (Bearish filled, read by a strategy, not drawn).
In a strategy. Buy the retest: with g = ctx.ind("fvg", atr_length=14, min_size=0.25, fill="half") a long limit at g.bull_top with the stop below g.bull_bottom, cancelled when g.bull_filled is 1.
The call with every input at its default:
pythonfvg = ctx.ind("fvg", atr_length=14, min_size=0.25, fill="full", max_zones=20)
fvg.bull_top, fvg.bull_bottom, fvg.bear_top, fvg.bear_bottom, fvg.bull_new, fvg.bear_new, fvg.bull_filled, fvg.bear_filledReference: ICT market structure, from public descriptions (#546).
Inversion fair value gaps (iFVG)
ifvg, drawn on the price.
What it measures. Fair value gaps that price has closed through, kept as zones of the opposite side: a bullish gap broken down turns into resistance, a bearish gap broken up into support.
Formula. Gaps are found as in fvg (third candle against the first, at least min_size ATRs). A bullish gap is inverted on the first close below its bottom and becomes a bearish zone with the same top and bottom; a bearish gap on the first close above its top becomes a bullish zone. An inverted zone ends on a close back through its far side: a bullish one below its bottom, a bearish one above its top.
How to read it. The lines show the nearest bullish zone (the highest) and the nearest bearish one (the lowest). new is 1 on the bar that inverts a gap, broken on the bar that ends a zone. Gaps waiting to be inverted and inverted zones are each kept up to max_zones per side.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| ATR length | atr_length | 14 | 1 to 500 |
| Minimum size (ATR) | min_size | 0.25 | 0.0 to 10.0 |
| Zones kept per side | max_zones | 20 | 1 to 500 |
Lines. bull_top (Bullish top), bull_bottom (Bullish bottom), bear_top (Bearish top), bear_bottom (Bearish bottom), bull_new (New bullish, read by a strategy, not drawn), bear_new (New bearish, read by a strategy, not drawn), bull_broken (Bullish broken, read by a strategy, not drawn) and bear_broken (Bearish broken, read by a strategy, not drawn).
In a strategy. Sell the retest of a broken gap: when z = ctx.ind("ifvg", atr_length=14, min_size=0.25) has z.bear_new of 1, a short limit at z.bear_bottom with the stop above z.bear_top.
The call with every input at its default:
pythonifvg = ctx.ind("ifvg", atr_length=14, min_size=0.25, max_zones=20)
ifvg.bull_top, ifvg.bull_bottom, ifvg.bear_top, ifvg.bear_bottom, ifvg.bull_new, ifvg.bear_new, ifvg.bull_broken, ifvg.bear_brokenReference: ICT market structure, from public descriptions (#546).
Order blocks (OB)
order_block, drawn on the price.
What it measures. The last opposite coloured candle before the move that broke structure, the zone where the move started and price often reacts when it comes back.
Formula. Swings and breaks as in structure. When a swing high breaks (BoS or CHoCH), take the lowest low between the swing and the break (the later on a tie); the last bearish candle at or before it is the bullish block, from its high to its low or, with Zone body, its body. Bearish blocks mirror this. A block ends on a close through its far side: a bullish one below its bottom.
How to read it. A block shows on the bar of the break that made it, never earlier, though its candle lies further back. The lines show the nearest active bullish block (the highest) and bearish one (the lowest); new and broken are 1 on the bar of the event. At most max_zones blocks per side are kept.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Swing bars each side | length | 3 | 1 to 50 |
| Break on | break_on | "close" | close (Close), wick (Wick) |
| Zone | zone | "wick" | wick (Full candle), body (Body only) |
| Zones kept per side | max_zones | 20 | 1 to 500 |
Lines. bull_top (Bullish top), bull_bottom (Bullish bottom), bear_top (Bearish top), bear_bottom (Bearish bottom), bull_new (New bullish, read by a strategy, not drawn), bear_new (New bearish, read by a strategy, not drawn), bull_broken (Bullish broken, read by a strategy, not drawn) and bear_broken (Bearish broken, read by a strategy, not drawn).
In a strategy. Buy the return to the block: with ob = ctx.ind("order_block", length=3, zone="body") a long limit at ob.bull_top and the stop below ob.bull_bottom, while the trend is up.
The call with every input at its default:
pythonorder_block = ctx.ind("order_block", length=3, break_on="close", zone="wick", max_zones=20)
order_block.bull_top, order_block.bull_bottom, order_block.bear_top, order_block.bear_bottom, order_block.bull_new, order_block.bear_new, order_block.bull_broken, order_block.bear_brokenReference: ICT market structure, from public descriptions (#546).
Breaker blocks
breaker_block, drawn on the price.
What it measures. Order blocks that failed: price closed through them, and they are kept as zones of the opposite side, a broken bullish block as resistance, a broken bearish one as support.
Formula. Order blocks as in order_block. A close below a bullish block's bottom turns it into a bearish breaker with the same top and bottom; a close above a bearish block's top into a bullish breaker. A breaker ends on a close back through its far side: a bullish one below its bottom, a bearish one above its top.
How to read it. The lines show the nearest bullish breaker (the highest) and bearish one (the lowest). new is 1 on the bar whose close turns a block into a breaker, broken on the bar that ends one. Order blocks and breakers are each kept up to max_zones per side.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Swing bars each side | length | 3 | 1 to 50 |
| Break on | break_on | "close" | close (Close), wick (Wick) |
| Zone | zone | "wick" | wick (Full candle), body (Body only) |
| Zones kept per side | max_zones | 20 | 1 to 500 |
Lines. bull_top (Bullish top), bull_bottom (Bullish bottom), bear_top (Bearish top), bear_bottom (Bearish bottom), bull_new (New bullish, read by a strategy, not drawn), bear_new (New bearish, read by a strategy, not drawn), bull_broken (Bullish broken, read by a strategy, not drawn) and bear_broken (Bearish broken, read by a strategy, not drawn).
In a strategy. Sell the retest after a failed long setup: when bb = ctx.ind("breaker_block", length=3) has bb.bear_new of 1, a short limit at bb.bear_bottom with the stop above bb.bear_top.
The call with every input at its default:
pythonbreaker_block = ctx.ind("breaker_block", length=3, break_on="close", zone="wick", max_zones=20)
breaker_block.bull_top, breaker_block.bull_bottom, breaker_block.bear_top, breaker_block.bear_bottom, breaker_block.bull_new, breaker_block.bear_new, breaker_block.bull_broken, breaker_block.bear_brokenReference: ICT market structure, from public descriptions (#546).
Fibonacci retracement
fib_retracement, drawn on the price.
What it measures. How far price has pulled back into the last swing leg, at the Fibonacci ratios 0.236, 0.382, 0.5, 0.618 and 0.786 between the last confirmed swing high and low.
Formula. Swings as in structure. The leg runs from the older of the last swing high and low to the newer: up when the high is newer. Each level is end minus ratio times (end minus start), so level_0 is the leg's end, level_1000 its start and level_618 the 0.618 retracement. leg is +1 for an up leg, -1 for a down leg.
How to read it. The levels move when a new swing is confirmed, length bars after its extreme, and hold until the next one. In an up leg the levels sit below the high, in a down leg above the low; nothing shows before the first swing high and low.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Swing bars each side | length | 3 | 1 to 50 |
Lines. level_0 (0), level_236 (0.236), level_382 (0.382), level_500 (0.5), level_618 (0.618), level_786 (0.786), level_1000 (1) and leg (Leg, read by a strategy, not drawn).
In a strategy. Buy a pullback in an up leg: when f = ctx.ind("fib_retracement", length=3) has f.leg of 1, a long limit at f.level_618 with the stop below f.level_1000, the leg's low.
The call with every input at its default:
pythonfib_retracement = ctx.ind("fib_retracement", length=3)
fib_retracement.level_0, fib_retracement.level_236, fib_retracement.level_382, fib_retracement.level_500, fib_retracement.level_618, fib_retracement.level_786, fib_retracement.level_1000, fib_retracement.legReference: Fibonacci retracement of the last swing leg (#546).
Fibonacci extension (Fib ext)
fib_extension, drawn on the price.
What it measures. Targets beyond the last swing leg: where the leg ends if it runs on 1.272, 1.618, 2 or 2.618 times its own length, measured from its start.
Formula. The leg as in fib_retracement: from the older of the last swing high and low to the newer. Each level is start plus ratio times (end minus start), so in an up leg the levels lie above the high and in a down leg below the low. leg is +1 for an up leg, -1 for a down leg.
How to read it. The levels move when a new swing is confirmed, length bars after its extreme, and hold until the next one. They are projections, not support or resistance that has been tested; nothing shows before the first swing high and low.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Swing bars each side | length | 3 | 1 to 50 |
Lines. level_1272 (1.272), level_1618 (1.618), level_2000 (2), level_2618 (2.618) and leg (Leg, read by a strategy, not drawn).
In a strategy. Take profit at a projection: a long opened in an up leg exits at ctx.ind("fib_extension", length=3).level_1618, or in parts at 1.272 and 1.618.
The call with every input at its default:
pythonfib_extension = ctx.ind("fib_extension", length=3)
fib_extension.level_1272, fib_extension.level_1618, fib_extension.level_2000, fib_extension.level_2618, fib_extension.legReference: Fibonacci extension of the last swing leg (#546).
Premium and discount (P/D)
premium_discount, drawn on the price.
What it measures. The dealing range between the last swing high and low, its middle (equilibrium) and whether price is in the upper half, premium, or the lower half, discount.
Formula. Swings as in structure. The range runs from the lower to the higher of the last confirmed swing high and low; equilibrium is their sum divided by 2. zone is +1 when the close is above equilibrium (premium), -1 below it (discount) and 0 exactly on it.
How to read it. The range moves when a new swing is confirmed, length bars after its extreme. Price can trade outside it until the next swing confirms; zone still says which side of equilibrium the close is on. Nothing shows before the first swing high and low.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Swing bars each side | length | 3 | 1 to 50 |
Lines. equilibrium (Equilibrium), range_high (Range high), range_low (Range low) and zone (Zone, read by a strategy, not drawn).
In a strategy. Buy only at a discount: take long setups while ctx.ind("premium_discount", length=3).zone is -1 and short setups while it is 1, with the target at .equilibrium or beyond.
The call with every input at its default:
pythonpremium_discount = ctx.ind("premium_discount", length=3)
premium_discount.equilibrium, premium_discount.range_high, premium_discount.range_low, premium_discount.zoneReference: ICT market structure, from public descriptions (#546).
Optimal trade entry (OTE)
ote, drawn on the price.
What it measures. The optimal trade entry zone: the 0.62 to 0.79 retracement of the last swing leg, where a pullback offers the best price before the leg resumes.
Formula. The leg as in fib_retracement. The zone's edges are end minus 0.62 times (end minus start) and end minus 0.79 times (end minus start); top is the higher, bottom the lower. inside is 1 when the close is between them, edges included. leg is +1 for an up leg, -1 for a down leg.
How to read it. In an up leg the zone sits in the lower part of the leg, a place to buy; in a down leg in the upper part, a place to sell. It moves when a new swing is confirmed, length bars after its extreme; nothing shows before the first swing high and low.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Swing bars each side | length | 3 | 1 to 50 |
Lines. top (OTE top), bottom (OTE bottom), inside (Inside, read by a strategy, not drawn) and leg (Leg, read by a strategy, not drawn).
In a strategy. Buy inside the zone of an up leg: when z = ctx.ind("ote", length=3) has z.leg of 1 and z.inside of 1, go long with the stop below the leg's low.
The call with every input at its default:
pythonote = ctx.ind("ote", length=3)
ote.top, ote.bottom, ote.inside, ote.legReference: ICT market structure, from public descriptions (#546).
Liquidity sweep (Sweep)
liquidity_sweep, drawn on the price.
What it measures. Stop runs: bars that trade beyond a swing high or low still holding liquidity and close back inside, the stops taken and the move rejected.
Formula. Swings as in structure; each stays liquidity until a later high trades above it (a low below, for lows), at most max_zones per side. up is 1 when a high takes such a level and the close is at or below it, down when a low takes one and the close is at or above it. A bar first takes the levels known before it. The level lines hold the last swept price, the highest one when a bar sweeps several.
How to read it. A sweep up takes buy stops above a high and fails there, often before a move down; a sweep down the mirror. A swing counts once it is confirmed, length bars after its extreme, and a level taken by a close beyond it is gone without a sweep.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Swing bars each side | length | 3 | 1 to 50 |
| Zones kept per side | max_zones | 20 | 1 to 500 |
Lines. up (Sweep up, read by a strategy, not drawn), down (Sweep down, read by a strategy, not drawn), up_level (Swept high) and down_level (Swept low).
In a strategy. Fade the stop run: when s = ctx.ind("liquidity_sweep", length=3) has s.down of 1, go long with the stop below the bar's low and the target at the nearest buy side liquidity.
The call with every input at its default:
pythonliquidity_sweep = ctx.ind("liquidity_sweep", length=3, max_zones=20)
liquidity_sweep.up, liquidity_sweep.down, liquidity_sweep.up_level, liquidity_sweep.down_levelReference: ICT liquidity concepts, from public descriptions (#546).
Equal highs and lows (EQH/EQL)
equal_levels, drawn on the price.
What it measures. Liquidity pools: two or more swing highs (or lows) at about the same price, where the stops of many traders sit together and price is drawn to take them.
Formula. Swings and liquidity as in liquidity_sweep. When a swing high is confirmed and an earlier high still untaken lies within tolerance times the ATR (Wilder, atr_length, at the confirming bar), the newest such high becomes a pool at its own price, the higher of the two. A pool is taken when a high trades above it. Lows mirror this. eqh is the lowest pool of highs, eql the highest pool of lows.
How to read it. The lines show the nearest pools above and below price; new is 1 on the bar that confirms the second swing, taken on the bar that trades through a pool. A pool shows length bars after the second extreme, never earlier.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Swing bars each side | length | 3 | 1 to 50 |
| ATR length | atr_length | 14 | 1 to 500 |
| Tolerance (ATR) | tolerance | 0.1 | 0.0 to 2.0 |
| Zones kept per side | max_zones | 20 | 1 to 500 |
Lines. eqh (Equal highs), eql (Equal lows), eqh_new (New equal highs, read by a strategy, not drawn), eql_new (New equal lows, read by a strategy, not drawn), eqh_taken (Equal highs taken, read by a strategy, not drawn) and eql_taken (Equal lows taken, read by a strategy, not drawn).
In a strategy. Target the pool: with q = ctx.ind("equal_levels", length=3, tolerance=0.1) a long takes profit at q.eqh, just below the stops resting above the equal highs.
The call with every input at its default:
pythonequal_levels = ctx.ind("equal_levels", length=3, atr_length=14, tolerance=0.1, max_zones=20)
equal_levels.eqh, equal_levels.eql, equal_levels.eqh_new, equal_levels.eql_new, equal_levels.eqh_taken, equal_levels.eql_takenReference: ICT liquidity concepts, from public descriptions (#546).
Buy and sell side liquidity (Liquidity)
liquidity, drawn on the price.
What it measures. Where the resting stops are: the nearest swing high no later price has traded above (buy side) and the nearest swing low none has traded below (sell side).
Formula. Swings as in structure. A confirmed swing high stays buy side liquidity until a later high trades above it, a swing low sell side liquidity until a later low trades below it; at most max_zones per side, the oldest dropped first. buy_side is the lowest untaken high, sell_side the highest untaken low. A bar first takes the levels known before it, then adds the swings it confirms.
How to read it. Untaken highs always lie at or above the latest high and untaken lows at or below the latest low, so the lines frame price. taken is 1 on the bar that trades through at least one level of that side; the line then moves on to the next level, or None when none is left.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Swing bars each side | length | 3 | 1 to 50 |
| Zones kept per side | max_zones | 20 | 1 to 500 |
Lines. buy_side (Buy side), sell_side (Sell side), buy_taken (Buy side taken, read by a strategy, not drawn) and sell_taken (Sell side taken, read by a strategy, not drawn).
In a strategy. Aim at the draw on liquidity: with q = ctx.ind("liquidity", length=5) a long targets q.buy_side and keeps its stop below q.sell_side.
The call with every input at its default:
pythonliquidity = ctx.ind("liquidity", length=3, max_zones=20)
liquidity.buy_side, liquidity.sell_side, liquidity.buy_taken, liquidity.sell_takenReference: ICT liquidity concepts, from public descriptions (#546).
Balanced price range (BPR)
bpr, drawn on the price.
What it measures. Balanced price ranges: the overlap of a bullish and a bearish fair value gap, a range price has crossed fast in both directions and often reacts to when it returns.
Formula. Gaps as in fvg (third candle against the first, at least min_size ATRs), filled or not; the last max_zones per side are kept. When a bar makes a gap, the newest earlier gap of the other side that overlaps it gives the range: from the higher bottom to the lower top. It takes the new gap's side: a bullish gap over a bearish one makes a bullish range. A range ends on a close through its far side.
How to read it. A range shows on the third candle of the newer gap, never earlier. The lines show the nearest bullish range (the highest) and bearish one (the lowest); new and broken are 1 on the bar of the event, and at most max_zones ranges per side are kept.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| ATR length | atr_length | 14 | 1 to 500 |
| Minimum size (ATR) | min_size | 0.25 | 0.0 to 10.0 |
| Zones kept per side | max_zones | 20 | 1 to 500 |
Lines. bull_top (Bullish top), bull_bottom (Bullish bottom), bear_top (Bearish top), bear_bottom (Bearish bottom), bull_new (New bullish, read by a strategy, not drawn), bear_new (New bearish, read by a strategy, not drawn), bull_broken (Bullish broken, read by a strategy, not drawn) and bear_broken (Bearish broken, read by a strategy, not drawn).
In a strategy. Buy the return into a bullish range: with r = ctx.ind("bpr", atr_length=14, min_size=0.25) a long limit at r.bull_top with the stop below r.bull_bottom.
The call with every input at its default:
pythonbpr = ctx.ind("bpr", atr_length=14, min_size=0.25, max_zones=20)
bpr.bull_top, bpr.bull_bottom, bpr.bear_top, bpr.bear_bottom, bpr.bull_new, bpr.bear_new, bpr.bull_broken, bpr.bear_brokenReference: ICT liquidity concepts, from public descriptions (#546).
Mitigation blocks (MB)
mitigation_block, drawn on the price.
What it measures. The candle that made a swing, after a failure swing breaks that swing: traders trapped there wait to get out at break even, so price often turns when it comes back.
Formula. Swings and breaks as in structure. Bearish: a swing low breaks while the last swing high, made after the low, is no higher than the swing high before it (no higher high, no liquidity taken). The last bearish candle at or before the low's extreme is the block, high to low or, with Zone body, its body. Bullish: a swing high breaks after a low no lower than the one before; the last bullish candle at or before the high. It ends on a close through its far side.
How to read it. The variant of ICT's public description: like a breaker, but the failed swing took no liquidity. A block shows on the bar of the break, never earlier. The lines show the nearest bullish block (the highest) and bearish one (the lowest); at most max_zones per side are kept.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Swing bars each side | length | 3 | 1 to 50 |
| Break on | break_on | "close" | close (Close), wick (Wick) |
| Zone | zone | "wick" | wick (Full candle), body (Body only) |
| Zones kept per side | max_zones | 20 | 1 to 500 |
Lines. bull_top (Bullish top), bull_bottom (Bullish bottom), bear_top (Bearish top), bear_bottom (Bearish bottom), bull_new (New bullish, read by a strategy, not drawn), bear_new (New bearish, read by a strategy, not drawn), bull_broken (Bullish broken, read by a strategy, not drawn) and bear_broken (Bearish broken, read by a strategy, not drawn).
In a strategy. Sell the return to the block: when m = ctx.ind("mitigation_block", length=3) has m.bear_new of 1, a short limit at m.bear_bottom with the stop above m.bear_top.
The call with every input at its default:
pythonmitigation_block = ctx.ind("mitigation_block", length=3, break_on="close", zone="wick", max_zones=20)
mitigation_block.bull_top, mitigation_block.bull_bottom, mitigation_block.bear_top, mitigation_block.bear_bottom, mitigation_block.bull_new, mitigation_block.bear_new, mitigation_block.bull_broken, mitigation_block.bear_brokenReference: ICT liquidity concepts, from public descriptions (#546).
Rejection blocks (RB)
rejection_block, drawn on the price.
What it measures. The long wick at a swing high or low, where price was pushed back hard; the range from the body to the wick's tip often rejects price again.
Formula. Swings as in structure. At a confirmed swing high, the candle of the extreme counts when its upper wick (high minus the higher of open and close) is above zero and at least min_wick times its range: the bearish block runs from that body edge up to the high. A swing low with a long lower wick gives a bullish block from the low up to the lower body edge. It ends on a close through its far side.
How to read it. The variant of ICT's public description, on the one candle of the swing extreme. A block shows when the swing is confirmed, length bars after the wick, never earlier. The lines show the nearest bullish block (the highest) and bearish one (the lowest); at most max_zones per side are kept.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Swing bars each side | length | 3 | 1 to 50 |
| Minimum wick (share of the candle) | min_wick | 0.5 | 0.0 to 1.0 |
| Zones kept per side | max_zones | 20 | 1 to 500 |
Lines. bull_top (Bullish top), bull_bottom (Bullish bottom), bear_top (Bearish top), bear_bottom (Bearish bottom), bull_new (New bullish, read by a strategy, not drawn), bear_new (New bearish, read by a strategy, not drawn), bull_broken (Bullish broken, read by a strategy, not drawn) and bear_broken (Bearish broken, read by a strategy, not drawn).
In a strategy. Sell into the wick: with r = ctx.ind("rejection_block", length=3, min_wick=0.5) a short limit at r.bear_bottom with the stop above r.bear_top, the wick's tip.
The call with every input at its default:
pythonrejection_block = ctx.ind("rejection_block", length=3, min_wick=0.5, max_zones=20)
rejection_block.bull_top, rejection_block.bull_bottom, rejection_block.bear_top, rejection_block.bear_bottom, rejection_block.bull_new, rejection_block.bear_new, rejection_block.bull_broken, rejection_block.bear_brokenReference: ICT liquidity concepts, from public descriptions (#546).
Displacement
displacement, drawn on the price.
What it measures. Displacement: a candle with a body far larger than usual that leaves a fair value gap behind, the footprint of large orders moving price in one go.
Formula. A bullish candle whose body (close minus open) is more than min_body times the ATR (Wilder, atr_length) at that candle, and which is the middle candle of a bullish gap as in fvg (the next candle's low above the high before it, at least min_size ATRs). Bearish mirrors this. up and down are 1 on the bar after the candle, which completes the gap; high, low and body_atr hold the last one's.
How to read it. The flag comes one bar after the large candle, because only the next candle shows whether it left a gap; it is never set earlier. high and low frame the candle that displaced price, a reference for entries on the retrace.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| ATR length | atr_length | 14 | 1 to 500 |
| Minimum size (ATR) | min_size | 0.25 | 0.0 to 10.0 |
| Minimum body (ATR) | min_body | 1.0 | 0.0 to 10.0 |
Lines. up (Displacement up, read by a strategy, not drawn), down (Displacement down, read by a strategy, not drawn), high (Candle high), low (Candle low) and body_atr (Body in ATR, read by a strategy, not drawn).
In a strategy. Trade with the displacement: when d = ctx.ind("displacement", min_body=1.5) has d.up of 1, look for longs on a pullback toward d.low.
The call with every input at its default:
pythondisplacement = ctx.ind("displacement", atr_length=14, min_size=0.25, min_body=1.0)
displacement.up, displacement.down, displacement.high, displacement.low, displacement.body_atrReference: ICT liquidity concepts, from public descriptions (#546).
Kill zones
killzones, drawn on the price, uses the bar's time.
What it measures. The ICT kill zones, the hours when the big centres move price most: Asia, the London open, the New York open and the London close, and each zone's high and low.
Formula. On the New York clock, daylight saving included: Asia 20:00 to 24:00, London open 02:00 to 05:00, New York open 07:00 to 10:00, London close 10:00 to 12:00, start included, end excluded, by the bar's start time. A trading day runs from 17:00 to 17:00 and takes the date of its end, so Sunday evening's Asia is Monday's; with Days Monday to Friday only those trading days count. A zone's high and low run from its first bar.
How to read it. The flags are 1 inside a zone and 0 outside, on every bar. A zone's high and low grow while it runs and then hold until the same zone starts on the next trading day, so the Asian range stays readable through London. A bar counts by its start time and the zones start on the hour, so use H1 or finer.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Days | days | "mon_fri" | mon_fri (Monday to Friday), every_day (Every day) |
Lines. asia (Asia, read by a strategy, not drawn), london_open (London open, read by a strategy, not drawn), new_york_open (New York open, read by a strategy, not drawn), london_close (London close, read by a strategy, not drawn), asia_high (Asia high), asia_low (Asia low), london_open_high (London open high), london_open_low (London open low), new_york_open_high (New York open high), new_york_open_low (New York open low), london_close_high (London close high) and london_close_low (London close low).
In a strategy. Trade only in the New York open: with k = ctx.ind("killzones", days="mon_fri") take entries while k.new_york_open is 1, and watch for a sweep of k.asia_high or k.asia_low in London.
The call with every input at its default:
pythonkillzones = ctx.ind("killzones", days="mon_fri")
killzones.asia, killzones.london_open, killzones.new_york_open, killzones.london_close, killzones.asia_high, killzones.asia_low, killzones.london_open_high, killzones.london_open_low, killzones.new_york_open_high, killzones.new_york_open_low, killzones.london_close_high, killzones.london_close_lowReference: ICT kill zones on the New York clock: Asia 20 to 24, London open 02 to 05, New York open 07 to 10, London close 10 to 12.
Midnight open
midnight_open, drawn on the price, uses the bar's time.
What it measures. The true day open of ICT: the price at 00:00 New York, and whether the close is above or below it, the reference for premium and discount within the day.
Formula. The open of the first bar that starts on a new New York date, daylight saving included; with Days Monday to Friday only those dates set it, and the open holds over the weekend. position is 1 when the close is above the open, -1 below it and 0 on it; first_bar is 1 on the bar that set the open.
How to read it. On H1 or finer the first bar of a date starts at midnight; coarser bars start later and the open is theirs. A forex Sunday evening keeps Friday's open until Monday 00:00. Above the open the day trades at a premium, below it at a discount.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Days | days | "mon_fri" | mon_fri (Monday to Friday), every_day (Every day) |
Lines. open (Midnight open), position (Close against the open, read by a strategy, not drawn) and first_bar (First bar, read by a strategy, not drawn).
In a strategy. Buy below the open on a bullish day: with m = ctx.ind("midnight_open", days="mon_fri") take long setups only while m.position is -1, under the true day open.
The call with every input at its default:
pythonmidnight_open = ctx.ind("midnight_open", days="mon_fri")
midnight_open.open, midnight_open.position, midnight_open.first_barReference: ICT midnight open (true day open): 00:00 on the New York clock.
Opening gaps (NWOG/NDOG)
opening_gaps, drawn on the price, uses the bar's time.
What it measures. The new week opening gap (NWOG) between Friday's close and the week's first open, and the new day opening gap (NDOG) between a day's last close and the next day's first open.
Formula. Trading days start at 17:00 New York, daylight saving included, weeks with Monday's. At a day's first bar the gap runs from the last close before it to its open: top the higher, bottom the lower. The first bar of a week sets the week's gap as well. A gap is filled once the bars from its first bar on have reached both its top and its bottom.
How to read it. filled is a state: 0 while the gap is open and 1 from the bar that closed it, and the levels stay until the next gap, since the old gap is still a reference. On round the clock forex data the day gap is often a pip or less; on futures the daily break makes it wider.
No inputs.
Lines. nwog_top (New week gap top), nwog_bottom (New week gap bottom), nwog_filled (New week gap filled, read by a strategy, not drawn), ndog_top (New day gap top), ndog_bottom (New day gap bottom) and ndog_filled (New day gap filled, read by a strategy, not drawn).
In a strategy. Trade toward the open gap: with g = ctx.ind("opening_gaps") and g.nwog_filled at 0, a position takes profit at g.nwog_bottom when price trades above the gap.
The call with every input at its default:
pythonopening_gaps = ctx.ind("opening_gaps")
opening_gaps.nwog_top, opening_gaps.nwog_bottom, opening_gaps.nwog_filled, opening_gaps.ndog_top, opening_gaps.ndog_bottom, opening_gaps.ndog_filledReference: ICT new week and new day opening gaps (NWOG, NDOG), on the 17:00 New York trading day.
Time
Trading sessions (Sessions)
sessions, drawn on the price, uses the bar's time.
What it measures. Which of the four FX centres is open on each bar, whether London and New York overlap, and the high and low of the session you follow, so far and of the last one.
Formula. Each centre is open while the bar's start time on its own clock, daylight saving included, is in its hours: Sydney 07:00 to 16:00, Tokyo 09:00 to 18:00, London and New York 08:00 to 17:00, open included, close excluded, on a local Monday to Friday unless Days says every day. The followed session's high and low run from its first bar; when it ends they become the previous high and low. Minutes count from the open to the bar's start.
How to read it. The flags are 1 while open and 0 otherwise, on every bar. London and New York change their clocks on different Sundays, so in those weeks the overlap is an hour longer in UTC, which the local clocks get right. A bar counts by its start time, so use H1 or finer. Holidays are not known, and a session the data starts inside counts from its first bar.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Session | session | "london" | london (London), new_york (New York), tokyo (Tokyo), sydney (Sydney) |
| Days | days | "mon_fri" | mon_fri (Monday to Friday), every_day (Every day) |
Lines. in_session (In session, read by a strategy, not drawn), high (Session high), low (Session low), prev_high (Previous high), prev_low (Previous low), first_bar (First bar, read by a strategy, not drawn), minutes (Minutes since open, read by a strategy, not drawn), sydney (Sydney, read by a strategy, not drawn), tokyo (Tokyo, read by a strategy, not drawn), london (London, read by a strategy, not drawn), new_york (New York, read by a strategy, not drawn) and overlap (London and New York, read by a strategy, not drawn).
In a strategy. A London breakout: with s = ctx.ind("sessions", session="london"), go long while s.overlap is 1 and the close breaks above s.prev_high, short below s.prev_low, or only trade while s.in_session is 1.
The call with every input at its default:
pythonsessions = ctx.ind("sessions", session="london", days="mon_fri")
sessions.in_session, sessions.high, sessions.low, sessions.prev_high, sessions.prev_low, sessions.first_bar, sessions.minutes, sessions.sydney, sessions.tokyo, sessions.london, sessions.new_york, sessions.overlapReference: FX session hours on each city's clock: Sydney 07 to 16, Tokyo 09 to 18, London and New York 08 to 17.
Prior period levels
prior_levels, drawn on the price, uses the bar's time.
What it measures. The open, high, low and close of the last finished day, week or month, and the open, high and low of the running one so far.
Formula. Periods turn as for pivot points: days start at 17:00 New York (daylight saving included) or, as Day starts chooses, at 00:00 UTC; weeks with Monday's day, months with the 1st. At the first bar of a new period the running period's open, high, low and last close become the previous ones; the running open, high and low then start from that bar. The previous values are empty until the first period in the data has ended.
How to read it. Yesterday's high and low are levels many traders watch: a break above the previous high or a rejection from it. With the default 17:00 New York day a forex Sunday evening already belongs to Monday, so Monday's previous day is Friday. A gap of several periods makes the last period with bars the previous one.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Period | period | "day" | day (Day), week (Week), month (Month) |
| Day starts | session | "ny" | ny (17:00 New York), utc (00:00 UTC) |
Lines. prev_high (Previous high), prev_low (Previous low), prev_close (Previous close), prev_open (Previous open), high (High so far), low (Low so far) and open (Open).
In a strategy. A breakout of yesterday's range: with p = ctx.ind("prior_levels", period="day") go long when the close crosses above p.prev_high and short when it crosses below p.prev_low, the stop at the other side.
The call with every input at its default:
pythonprior_levels = ctx.ind("prior_levels", period="day", session="ny")
prior_levels.prev_high, prior_levels.prev_low, prior_levels.prev_close, prior_levels.prev_open, prior_levels.high, prior_levels.low, prior_levels.openReference: Prior day, week and month high, low, open and close, on the trading day pivot points use.
Opening range (OR)
opening_range, drawn on the price, uses the bar's time.
What it measures. The high and low of the first minutes after a market opens, the range's middle and size, the size against a daily ATR, and where the close is against the range.
Formula. The window runs from the open (hour and minute on the chosen clock, daylight saving included) for the set minutes, cut at local midnight, every local day. High and low are those of the bars that start inside it; mid is their mean, size their difference. size_atr is size divided by Wilder's ATR over the finished local days. position is 1 above the high, -1 below the low, 0 inside.
How to read it. Nothing shows until the window has closed, at the close of the bar that reaches its end, so a strategy never acts on a range still forming; from local midnight it is empty again until the next window closes. A bar counts when it starts inside, so a 09:30 window needs M30 or finer. Frankfurt's 09:00 is 08:00 London, the same instant all year.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Clock | zone | "new_york" | utc (UTC), london (London), new_york (New York), tokyo (Tokyo), sydney (Sydney) |
| Open hour | hour | 9 | 0 to 23 |
| Open minute | minute | 30 | 0 to 59 |
| Range minutes | minutes | 30 | 1 to 1440 |
| ATR days | atr_length | 14 | 1 to 200 |
Lines. high (Range high), low (Range low), mid (Range middle), size (Range size, read by a strategy, not drawn), size_atr (Size in daily ATR, read by a strategy, not drawn) and position (Close against the range, read by a strategy, not drawn).
In a strategy. An opening range breakout: with r = ctx.ind("opening_range", zone="new_york", hour=9, minute=30, minutes=30) go long when r.position turns 1 and short when it turns -1, skipping days where r.size_atr is above 0.5.
The call with every input at its default:
pythonopening_range = ctx.ind("opening_range", zone="new_york", hour=9, minute=30, minutes=30, atr_length=14)
opening_range.high, opening_range.low, opening_range.mid, opening_range.size, opening_range.size_atr, opening_range.positionReference: Opening range (Crabel 1990), on the zone's wall clock.
Seasonality
seasonality, drawn in a pane of its own, uses the bar's time.
What it measures. How the instrument did in the past in periods like the current one: the mean return, the share that went up and a t statistic for the bar's month, weekday, turn of the month or hour.
Formula. Periods are hours, days or months on the chosen clock. When one ends, its return (last close divided by the last close of the period before, minus 1) joins its bucket: the hour 0 to 23, the weekday 0 (Monday) to 6, the turn of the month (the last weekday and the first three of a month) as 1 against 0, or the month 1 to 12. t_stat is the mean divided by the sample deviation over the square root of the count.
How to read it. The running period never counts, so a bar never feeds the number it reads. Mean, share and t wait for the minimum count. Small samples are noisy, and an effect found by looking at many buckets is often luck: a t around 2 from a dozen returns is weak evidence, and it assumes the returns are independent, which they rarely are.
Inputs
| Input | Id | Default | Range |
|---|---|---|---|
| Group by | by | "weekday" | month (Month), weekday (Weekday), turn_of_month (Turn of the month), hour (Hour) |
| Clock | zone | "utc" | utc (UTC), london (London), new_york (New York), tokyo (Tokyo), sydney (Sydney) |
| Minimum returns | min_count | 10 | 2 to 1000 |
Lines. mean (Mean return), hit_rate (Share up, read by a strategy, not drawn), t_stat (t statistic, read by a strategy, not drawn), count (Returns in the bucket, read by a strategy, not drawn) and bucket (Bucket, read by a strategy, not drawn).
In a strategy. As a filter: with s = ctx.ind("seasonality", by="weekday", min_count=20) take longs only while s.mean is above 0 and s.t_stat above 2, or skip the turn of the month with by="turn_of_month".
The call with every input at its default:
pythonseasonality = ctx.ind("seasonality", by="weekday", zone="utc", min_count=10)
seasonality.mean, seasonality.hit_rate, seasonality.t_stat, seasonality.count, seasonality.bucketReference: Calendar effects: day of the week, turn of the month (Ariel 1987), month of the year.