# Sift language reference

> The complete reference for Sift: clauses, fields, indicators, window functions, sugar and event operators for screening NSE equities.

Canonical: https://patternsradar.com/docs/sift

A query is one condition, with optional clauses around it:

```sift
on daily
from NSE
where close > ema(21) > ema(50)
  and volume > 2x avg(volume, 20)
  and delivery_pct > 55
sort by turnover desc
top 25
```

Clauses may appear in any order, and a bare condition is a complete query. Newlines and indentation carry no meaning; `#` or `//` starts a comment. Sift is not Turing complete — no loops, no user-defined functions, no side effects — which is what lets the editor underline a mistake before anything runs.

## Query shape

| Clause | Purpose | Default |
|---|---|---|
| on | Candle timeframe. | daily — the only one this dataset carries |
| from | Which universe to scan: `NSE` (all equities) or `fno` (stocks with listed futures & options). | NSE |
| where | The condition. Optional keyword. | everything matches |
| sort by | Order the results by any expression. | turnover, descending |
| top | Row cap. | 300 |

`sort by` accepts any expression, not just a returned column — `sort by (close - ema(50)) / ema(50) desc` ranks by distance above the average.

## Fields — Price

| Field | Label | Description | Glossary |
|---|---|---|---|
| `close` | Close | Closing price, adjusted for splits and bonuses. | — |
| `open` | Open | Opening price. | — |
| `high` | High | Session high. | — |
| `low` | Low | Session low. | — |
| `hl2` | HL2 | Midpoint of the session range. | — |
| `hlc3` | HLC3 | Typical price. | — |
| `ohlc4` | OHLC4 | Average of all four session prices. | — |
| `ha_open` | Heikin-Ashi open | Heikin-Ashi open — the average of the previous HA open and close. | [Heikin-Ashi candles](https://patternsradar.com/learn/heikin-ashi.md) |
| `ha_high` | Heikin-Ashi high | Heikin-Ashi high. | [Heikin-Ashi candles](https://patternsradar.com/learn/heikin-ashi.md) |
| `ha_low` | Heikin-Ashi low | Heikin-Ashi low. | [Heikin-Ashi candles](https://patternsradar.com/learn/heikin-ashi.md) |
| `ha_close` | Heikin-Ashi close | Heikin-Ashi close — the average of the bar's four prices. | [Heikin-Ashi candles](https://patternsradar.com/learn/heikin-ashi.md) |
| `high_52w` | 52-week high | Highest high of the last 252 sessions. | [52-week high and low](https://patternsradar.com/learn/52-week-high-low.md) |
| `low_52w` | 52-week low | Lowest low of the last 252 sessions. | [52-week high and low](https://patternsradar.com/learn/52-week-high-low.md) |
| `pct_from_52w_high` | % from 52w high | Distance below the 52-week high, as a negative percentage. | [52-week high and low](https://patternsradar.com/learn/52-week-high-low.md) |
| `pct_from_52w_low` | % from 52w low | Distance above the 52-week low, as a percentage. | [52-week high and low](https://patternsradar.com/learn/52-week-high-low.md) |
| `pivot` | Pivot point | Classic floor-trader pivot from the previous session. | [Pivot points](https://patternsradar.com/learn/pivot-points.md) |
| `pivot_r1` | Pivot R1 | First resistance above the pivot. | [Pivot points](https://patternsradar.com/learn/pivot-points.md) |
| `pivot_r2` | Pivot R2 | Second resistance above the pivot. | [Pivot points](https://patternsradar.com/learn/pivot-points.md) |
| `pivot_s1` | Pivot S1 | First support below the pivot. | [Pivot points](https://patternsradar.com/learn/pivot-points.md) |
| `pivot_s2` | Pivot S2 | Second support below the pivot. | [Pivot points](https://patternsradar.com/learn/pivot-points.md) |

## Fields — Volume & delivery

| Field | Label | Description | Glossary |
|---|---|---|---|
| `volume` | Volume | Shares traded. | — |
| `turnover` | Turnover | Close × volume, in rupees. | [Turnover](https://patternsradar.com/learn/turnover.md) |
| `trades` | Trades | Number of trades executed. | — |
| `delivery_pct` | Delivery % | Share of volume taken to demat rather than squared off intraday. High delivery on a rising day suggests genuine accumulation. | [Delivery percentage](https://patternsradar.com/learn/delivery-percentage.md) |
| `delivery_qty` | Delivery quantity | Shares taken to demat. | [Delivery percentage](https://patternsradar.com/learn/delivery-percentage.md) |
| `rel_volume` | Relative volume | Volume divided by its own 20-day average. 2 means twice normal. | [Relative volume (RVOL)](https://patternsradar.com/learn/relative-volume.md) |
| `obv` | On-balance volume | Running total of volume signed by the day's direction. | [On-balance volume (OBV)](https://patternsradar.com/learn/on-balance-volume.md) |
| `acc_dist` | Accumulation/Distribution | Running total weighted by where the close sits in the range. | [Accumulation/Distribution line](https://patternsradar.com/learn/accumulation-distribution.md) |
| `cmf` | Chaikin money flow (20) | Accumulation/distribution normalised over 20 bars. Positive means buying pressure. | [Chaikin Money Flow (CMF)](https://patternsradar.com/learn/chaikin-money-flow.md) |
| `force_index` | Force index (13) | Price change times volume, smoothed over 13 bars. | [Force index](https://patternsradar.com/learn/force-index.md) |

## Fields — Momentum

| Field | Label | Description | Glossary |
|---|---|---|---|
| `stoch_k` | Stochastic %K | Slow stochastic %K over 14 bars, smoothed by 3. | — |
| `stoch_d` | Stochastic %D | 3-bar average of stochastic %K. | — |
| `stoch_rsi` | Stochastic RSI | The stochastic oscillator applied to RSI itself. | [Stochastic RSI](https://patternsradar.com/learn/stochastic-rsi.md) |
| `cci` | CCI (20) | Commodity Channel Index over the typical price. | [CCI (Commodity Channel Index)](https://patternsradar.com/learn/cci.md) |
| `williams_r` | Williams %R | Like the stochastic, scaled −100 to 0. | [Williams %R](https://patternsradar.com/learn/williams-r.md) |
| `mfi` | Money flow index (14) | A volume-weighted RSI over the typical price. | [MFI (Money Flow Index)](https://patternsradar.com/learn/mfi.md) |
| `roc` | Rate of change (10) | Percentage change over 10 bars. | [Rate of change (ROC)](https://patternsradar.com/learn/rate-of-change.md) |

## Fields — Trend

| Field | Label | Description | Glossary |
|---|---|---|---|
| `adx` | ADX (14) | Trend strength, direction-agnostic. Above 25 is usually read as trending. | [ADX (Average Directional Index)](https://patternsradar.com/learn/adx.md) |
| `di_plus` | DI+ | Positive directional indicator. | — |
| `di_minus` | DI− | Negative directional indicator. | — |
| `supertrend` | Supertrend | ATR-banded trailing stop (10, 3). | [Supertrend indicator](https://patternsradar.com/learn/supertrend.md) |
| `supertrend_dir` | Supertrend direction | +1 while Supertrend is bullish, −1 while bearish. | — |
| `psar` | Parabolic SAR | Parabolic stop-and-reverse (0.02, 0.2). | — |
| `aroon_up` | Aroon up | How recently the 25-bar high occurred. | [Aroon indicator](https://patternsradar.com/learn/aroon.md) |
| `aroon_down` | Aroon down | How recently the 25-bar low occurred. | [Aroon indicator](https://patternsradar.com/learn/aroon.md) |
| `aroon_osc` | Aroon oscillator | Aroon up minus Aroon down. | [Aroon indicator](https://patternsradar.com/learn/aroon.md) |
| `ichimoku_conversion` | Ichimoku conversion | Tenkan-sen, the 9-bar midpoint. | — |
| `ichimoku_base` | Ichimoku base | Kijun-sen, the 26-bar midpoint. | — |
| `ichimoku_span_a` | Ichimoku span A | Cloud edge A, unshifted. | — |
| `ichimoku_span_b` | Ichimoku span B | Cloud edge B, unshifted. | — |

## Fields — Volatility

| Field | Label | Description | Glossary |
|---|---|---|---|
| `atr` | ATR (14) | Wilder's average true range over 14 bars. | [ATR (Average True Range)](https://patternsradar.com/learn/atr.md) |
| `true_range` | True range | This bar's true range. | [True range](https://patternsradar.com/learn/true-range.md) |
| `bb_upper` | Bollinger upper | 20-period SMA plus two standard deviations. | — |
| `bb_mid` | Bollinger middle | 20-period simple moving average. | — |
| `bb_lower` | Bollinger lower | 20-period SMA minus two standard deviations. | — |
| `bb_pct_b` | Bollinger %B | Where the close sits within the bands: 0 at the lower, 1 at the upper. | — |
| `bb_width` | Bollinger width | Band separation as a fraction of the middle band. Low means a squeeze. | — |
| `donchian_upper` | Donchian upper | Highest high of the last 20 bars. | — |
| `donchian_mid` | Donchian middle | Midpoint of the Donchian channel. | — |
| `donchian_lower` | Donchian lower | Lowest low of the last 20 bars. | — |
| `keltner_upper` | Keltner upper | 20-EMA plus two ATRs. | — |
| `keltner_lower` | Keltner lower | 20-EMA minus two ATRs. | — |

## Fields — Performance

| Field | Label | Description | Glossary |
|---|---|---|---|
| `change` | 1-day change % | Percentage change against the previous close. | — |
| `return_1w` | 1-week return % | Percentage change over 5 sessions. | — |
| `return_1m` | 1-month return % | Percentage change over 21 sessions. | — |
| `return_3m` | 3-month return % | Percentage change over 63 sessions. | — |
| `return_6m` | 6-month return % | Percentage change over 126 sessions. | — |
| `return_1y` | 1-year return % | Percentage change over 252 sessions. | — |

## Fields — Derivatives (F&O)

| Field | Label | Description | Glossary |
|---|---|---|---|
| `fut_oi` | Futures OI | Total futures open interest across all expiries, in contracts. | — |
| `fut_oi_change_pct` | Futures OI change % | Day-over-day change in total futures OI. Read it with price: price up with OI up is long buildup, price down with OI up is short buildup. The drop after an expiry day is genuine, not noise. | — |
| `fut_volume` | Futures volume | Futures contracts traded across all expiries. | — |
| `fut_basis_pct` | Futures basis % | Front-month futures premium (positive) or discount (negative) to the cash price, in percent. Compared on the raw price scale — corporate actions are bridged out. Reads near zero on expiry day by construction. | — |
| `fut_rollover_pct` | Rollover % | Share of futures OI already sitting in later expiries. On expiry day this is the classic rollover number the derivatives desks quote. | — |
| `pcr_oi` | Put-call ratio (OI) | Put OI divided by call OI across this stock's options, all expiries. Above 1 means more open puts than calls. NULL when no calls are open. | — |
| `pcr_vol` | Put-call ratio (volume) | Put contracts traded divided by call contracts traded, all expiries. | — |

## Fields — Fundamentals

| Field | Label | Description | Glossary |
|---|---|---|---|
| `marketcap` | Market cap | Close times shares outstanding, in rupees — write `marketcap > 5000cr`. The share count is restated onto the adjusted-price basis, so a split does not fake a jump. | — |
| `pe` | P/E (TTM) | Price to trailing-twelve-month earnings, from the last four filed quarters as known on that date. NULL when TTM earnings are negative or not yet filed — a loss-maker has no P/E rather than a misleading one. | — |
| `eps_ttm` | EPS (TTM) | Trailing-twelve-month earnings per share, split-adjusted to match the adjusted price series (filed EPS is not — it is never used directly). Negative for loss-makers, NULL until four consecutive quarters are on file. | — |
| `revenue_growth_yoy` | Revenue growth YoY % | Latest filed quarter's revenue against the same quarter last year. | — |
| `profit_growth_yoy` | Profit growth YoY % | Latest filed quarter's net profit against the same quarter last year. NULL when the base quarter was a loss — growth from negative earnings is not a number. | — |
| `revenue_growth_qoq` | Revenue growth QoQ % | Latest filed quarter's revenue against the previous quarter. | — |
| `profit_growth_qoq` | Profit growth QoQ % | Latest filed quarter's net profit against the previous quarter. NULL when the base quarter was a loss. | — |
| `profit_cagr_2y` | Profit CAGR 2y % | Annualized growth in trailing-twelve-month net profit over two years — the shortest window where compounding says anything a single YoY does not. | — |
| `profit_cagr_3y` | Profit CAGR 3y % | Annualized growth in trailing-twelve-month net profit over three years. Wider coverage than the five-year window, and long enough to outlast one soft base year. | — |
| `profit_cagr_4y` | Profit CAGR 4y % | Annualized growth in trailing-twelve-month net profit over four years. | — |
| `profit_cagr_5y` | Profit CAGR 5y % | Annualized growth in trailing-twelve-month net profit over five years — the usual test of whether earnings compound or merely cycle. A company needs five unbroken years of filings on one basis to get a number; about half of covered names do. | — |
| `profit_cagr_6y` | Profit CAGR 6y % | Annualized growth in trailing-twelve-month net profit over six years. Sparse — few names have this much filed history yet. | — |
| `profit_cagr_7y` | Profit CAGR 7y % | Annualized growth in trailing-twelve-month net profit over seven years — the longest window the results store reaches, and the sparsest. | — |
| `revenue_cagr_2y` | Revenue CAGR 2y % | Annualized growth in trailing-twelve-month revenue over two years. | — |
| `revenue_cagr_3y` | Revenue CAGR 3y % | Annualized growth in trailing-twelve-month revenue over three years. | — |
| `revenue_cagr_4y` | Revenue CAGR 4y % | Annualized growth in trailing-twelve-month revenue over four years. | — |
| `revenue_cagr_5y` | Revenue CAGR 5y % | Annualized growth in trailing-twelve-month revenue over five years. Pair it with `profit_cagr_5y` to separate operating leverage from growth that only arrived through the top line. | — |
| `revenue_cagr_6y` | Revenue CAGR 6y % | Annualized growth in trailing-twelve-month revenue over six years. | — |
| `revenue_cagr_7y` | Revenue CAGR 7y % | Annualized growth in trailing-twelve-month revenue over seven years. | — |
| `interest_cost_growth_yoy` | Interest cost growth YoY % | Trailing-twelve-month finance costs against a year earlier. This is a proxy for the direction of borrowing, not a measure of it: quarterly filings carry a P&L and no balance sheet, so there is no debt figure here to read — flat interest beside growing profit is the shape of growth funded from earnings, and a jump is the shape of fresh debt. Read it against `pe` and a profit CAGR, exclude lenders (for a bank interest is the cost of goods, not leverage), and expect NULL when a quarter's finance-cost line is missing. | — |
| `promoter_pct` | Promoter holding % | Promoter shareholding from the latest pattern filed by that date. | — |
| `public_pct` | Public holding % | Public shareholding from the latest pattern filed by that date. | — |
| `fii_pct` | FII holding % | Foreign institutional holding from the latest pattern filed by that date. Sparse until the shareholding XBRL backfill completes. | — |
| `dii_pct` | DII holding % | Domestic institutional holding from the latest pattern filed by that date. Sparse until the shareholding XBRL backfill completes. | — |
| `promoter_pledged_pct` | Promoter pledged % | Share of the promoter stake pledged as collateral. Zero is the healthy reading; a rising number is the classic distress tell. | — |
| `promoter_change_qoq` | Promoter change QoQ | Percentage-point change in promoter holding against the previous quarter's pattern. Positive means promoters bought. | — |

## Sectors & categories

Category fields hold a closed set of string values and are tested with `is`, `is not` or `in` — never arithmetic. Matching is case-insensitive; the compiler canonicalises onto NSE's official spelling.

| Form | Meaning |
|---|---|
| sector is "Information Technology" | Exactly this NSE sector. |
| sector is not "Financial Services" | Everything but this sector. |
| industry in ("Banks", "Finance") | Any of the listed industries. |
| macro_sector is "Consumer Discretionary" | The broadest tier, above sector. |

### Sector (`sector`, 22 values)

`Automobile and Auto Components`, `Capital Goods`, `Chemicals`, `Construction`, `Construction Materials`, `Consumer Durables`, `Consumer Services`, `Diversified`, `Fast Moving Consumer Goods`, `Financial Services`, `Forest Materials`, `Healthcare`, `Information Technology`, `Media Entertainment & Publication`, `Metals & Mining`, `Oil Gas & Consumable Fuels`, `Power`, `Realty`, `Services`, `Telecommunication`, `Textiles`, `Utilities`

### Macro sector (`macro_sector`, 12 values)

`Commodities`, `Consumer Discretionary`, `Diversified`, `Energy`, `Fast Moving Consumer Goods`, `Financial Services`, `Healthcare`, `Industrials`, `Information Technology`, `Services`, `Telecommunication`, `Utilities`

### Industry (`industry`, 58 values)

`Aerospace & Defense`, `Agricultural Commercial & Construction Vehicles`, `Agricultural Food & other Products`, `Auto Components`, `Automobiles`, `Banks`, `Beverages`, `Capital Markets`, `Cement & Cement Products`, `Chemicals & Petrochemicals`, `Cigarettes & Tobacco Products`, `Commercial Services & Supplies`, `Construction`, `Consumable Fuels`, `Consumer Durables`, `Diversified`, `Diversified FMCG`, `Diversified Metals`, `Electrical Equipment`, `Engineering Services`, `Entertainment`, `Ferrous Metals`, `Fertilizers & Agrochemicals`, `Finance`, `Financial Technology (Fintech)`, `Food Products`, `Gas`, `Healthcare Equipment & Supplies`, `Healthcare Services`, `Household Products`, `IT - Hardware`, `IT - Services`, `IT - Software`, `Industrial Manufacturing`, `Industrial Products`, `Insurance`, `Leisure Services`, `Media`, `Metals & Minerals Trading`, `Minerals & Mining`, `Non - Ferrous Metals`, `Oil`, `Other Construction Materials`, `Other Consumer Services`, `Other Utilities`, `Paper Forest & Jute Products`, `Personal Products`, `Petroleum Products`, `Pharmaceuticals & Biotechnology`, `Power`, `Printing & Publication`, `Realty`, `Retailing`, `Telecom - Equipment & Accessories`, `Telecom - Services`, `Textiles & Apparels`, `Transport Infrastructure`, `Transport Services`

Classification is today's snapshot — NSE publishes no history, so a historical scan applies the current sector retroactively.

## Derivatives fields

Per-stock daily aggregates from the NSE F&O bhavcopy; OI is in contracts across all expiries. NULL for the ~1,800 stocks without listed derivatives — `from fno` scopes a scan to the ~200 that have them.

| Field | Meaning |
|---|---|
| fut_oi | Total futures open interest, in contracts. |
| fut_oi_change_pct | Day-over-day change in futures OI. Rising OI with rising price is a long buildup. |
| fut_volume | Futures contracts traded. |
| fut_basis_pct | Front-month futures premium (+) or discount (−) to cash. |
| fut_rollover_pct | Share of OI already in later expiries. |
| pcr_oi | Put-call ratio by open interest. |
| pcr_vol | Put-call ratio by contracts traded. |

## Fundamentals fields

Point-in-time: a scan sees the numbers as the market knew them on the scan date. A result filed after the 15:30 close is visible from the next session; a revision counts from its own filing date. Coverage is partial while the filings backfill completes — missing data is NULL and never matches.

| Field | Meaning |
|---|---|
| marketcap | Close × shares outstanding, in rupees — `marketcap > 5000cr`. |
| pe | Price to trailing-twelve-month earnings. NULL for loss-makers rather than a misleading number. |
| eps_ttm | Trailing EPS, split-adjusted to match the adjusted price series. |
| revenue_growth_yoy / profit_growth_yoy | Latest filed quarter against the same quarter last year. |
| revenue_growth_qoq / profit_growth_qoq | Latest filed quarter against the previous quarter. |
| profit_cagr_2y … profit_cagr_7y | Annualized profit growth over N years, trailing twelve months against the TTM N years earlier. NULL when the history is short or either end was a loss. |
| revenue_cagr_2y … revenue_cagr_7y | The same window on revenue — pair with the profit CAGR to see whether margins widened or only sales did. |
| interest_cost_growth_yoy | TTM finance costs against a year ago. A proxy for the direction of borrowing, not a debt figure — quarterly filings carry no balance sheet. |
| promoter_pct / public_pct / fii_pct / dii_pct | Shareholding from the latest pattern filed by the scan date. |
| promoter_pledged_pct | Share of the promoter stake pledged as collateral. |
| promoter_change_qoq | Percentage-point change in promoter holding vs the previous quarter. |

## Indicators

Indicators take a period and default their source to close. Multi-output ones use dot access (`macd().line`, `bb().upper`).

| Indicator | Label | Periods | Members | Description | Glossary |
|---|---|---|---|---|---|
| `sma` | Simple moving average | 5, 10, 20, 50, 100, 200 (any) | — | Unweighted mean close over the period. | [SMA (Simple Moving Average)](https://patternsradar.com/learn/sma.md) |
| `ema` | Exponential moving average | 9, 21, 50, 200 (any) | — | Exponentially weighted mean close, seeded from the SMA. | [EMA (Exponential Moving Average)](https://patternsradar.com/learn/ema.md) |
| `wma` | Weighted moving average | 20 (any) | — | Linearly weighted mean — the newest bar counts most. | [WMA (Weighted Moving Average)](https://patternsradar.com/learn/wma.md) |
| `hma` | Hull moving average | 21 (any) | — | Hull's low-lag moving average. | [Hull Moving Average (HMA)](https://patternsradar.com/learn/hma.md) |
| `tema` | Triple EMA | 20 (any) | — | Triple-smoothed EMA, with much of the lag removed. | [TEMA (Triple EMA)](https://patternsradar.com/learn/tema.md) |
| `rma` | Wilder moving average | 14 (any) | — | Wilder's smoothing, as used inside RSI and ATR. | [Wilder Moving Average (RMA)](https://patternsradar.com/learn/wilder-moving-average.md) |
| `vwma` | Volume-weighted moving average | 20 (any) | — | Mean close weighted by each bar's volume. | [VWMA (Volume-Weighted Moving Average)](https://patternsradar.com/learn/vwma.md) |
| `rsi` | RSI | 14 (any) | — | Wilder's relative strength index. | [RSI (Relative Strength Index)](https://patternsradar.com/learn/rsi.md) |
| `atr` | ATR | 14 (any) | — | Wilder's average true range. | [ATR (Average True Range)](https://patternsradar.com/learn/atr.md) |
| `adx` | ADX | 14 (any) | — | Trend strength, direction-agnostic. | [ADX (Average Directional Index)](https://patternsradar.com/learn/adx.md) |
| `cci` | CCI | 20 (any) | — | Commodity Channel Index. | [CCI (Commodity Channel Index)](https://patternsradar.com/learn/cci.md) |
| `mfi` | Money flow index | 14 (any) | — | Volume-weighted RSI. | [MFI (Money Flow Index)](https://patternsradar.com/learn/mfi.md) |
| `cmf` | Chaikin money flow | 20 (any) | — | Accumulation/distribution normalised over a window. | [Chaikin Money Flow (CMF)](https://patternsradar.com/learn/chaikin-money-flow.md) |
| `roc` | Rate of change | 10 (any) | — | Percentage change over the period. | [Rate of change (ROC)](https://patternsradar.com/learn/rate-of-change.md) |
| `williams_r` | Williams %R | 14 (any) | — | Like the stochastic, scaled −100 to 0. | [Williams %R](https://patternsradar.com/learn/williams-r.md) |
| `macd` | MACD | — (any) | line, signal, hist | 12/26 EMA difference, with a 9-period signal line. | [MACD](https://patternsradar.com/learn/macd.md) |
| `bb` | Bollinger bands | — (any) | upper, mid, middle, lower, pctb, width | 20-period SMA with two-standard-deviation bands. | [Bollinger Bands](https://patternsradar.com/learn/bollinger-bands.md) |
| `stoch` | Stochastic | — (any) | k, d | Slow stochastic oscillator. | [Stochastic oscillator](https://patternsradar.com/learn/stochastic.md) |
| `supertrend` | Supertrend | — (any) | value, dir, direction | ATR-banded trailing stop. | [Supertrend indicator](https://patternsradar.com/learn/supertrend.md) |
| `donchian` | Donchian channel | — (any) | upper, mid, lower | The rolling 20-bar high/low envelope. | [Donchian channel](https://patternsradar.com/learn/donchian-channel.md) |
| `keltner` | Keltner channel | — (any) | upper, lower | A 20-EMA with ATR-scaled bands. | [Keltner channel](https://patternsradar.com/learn/keltner-channel.md) |
| `ichimoku` | Ichimoku | — (any) | conversion, base, span_a, span_b | Conversion, base and cloud edges. | [Ichimoku Cloud](https://patternsradar.com/learn/ichimoku.md) |
| `aroon` | Aroon | — (any) | up, down, osc | How recently the window's extremes occurred. | [Aroon indicator](https://patternsradar.com/learn/aroon.md) |

## Candlestick patterns

Used as `pattern is <name>`, optionally `within N bars`.

| Pattern | Label | Description | Glossary |
|---|---|---|---|
| `doji` | Doji | Open and close nearly equal — indecision. | [Doji candlestick](https://patternsradar.com/learn/doji.md) |
| `hammer` | Hammer | Long lower wick, small body at the top. | [Hammer candlestick pattern](https://patternsradar.com/learn/hammer.md) |
| `shooting_star` | Shooting star | Long upper wick, small body at the bottom. | [Shooting star candlestick](https://patternsradar.com/learn/shooting-star.md) |
| `marubozu` | Marubozu | Almost no wicks — one side controlled the session. | [Marubozu candlestick](https://patternsradar.com/learn/marubozu.md) |
| `bullish_engulfing` | Bullish engulfing | An up bar whose body swallows the previous down bar. | [Bullish engulfing pattern](https://patternsradar.com/learn/bullish-engulfing.md) |
| `bearish_engulfing` | Bearish engulfing | A down bar whose body swallows the previous up bar. | [Bearish engulfing pattern](https://patternsradar.com/learn/bearish-engulfing.md) |
| `bullish_harami` | Bullish harami | A small up bar contained inside the previous down bar. | [Bullish harami pattern](https://patternsradar.com/learn/bullish-harami.md) |
| `bearish_harami` | Bearish harami | A small down bar contained inside the previous up bar. | [Bearish harami pattern](https://patternsradar.com/learn/bearish-harami.md) |
| `morning_star` | Morning star | Down bar, pause, then a strong up bar through the midpoint. | [Morning star pattern](https://patternsradar.com/learn/morning-star.md) |
| `evening_star` | Evening star | Up bar, pause, then a strong down bar through the midpoint. | [Evening star pattern](https://patternsradar.com/learn/evening-star.md) |
| `three_white_soldiers` | Three white soldiers | Three consecutive strong up bars. | [Three white soldiers pattern](https://patternsradar.com/learn/three-white-soldiers.md) |
| `three_black_crows` | Three black crows | Three consecutive strong down bars. | [Three black crows pattern](https://patternsradar.com/learn/three-black-crows.md) |
| `inside_bar` | Inside bar | Range contained entirely within the previous bar's. | [Inside bar pattern](https://patternsradar.com/learn/inside-bar.md) |
| `outside_bar` | Outside bar | Range containing the whole previous bar's. | [Outside bar pattern](https://patternsradar.com/learn/outside-bar.md) |

## Universes

Liquidity tiers ranked by 20-day average turnover — not index membership:

- 100: Most traded 100 stocks by 20-day turnover
- 250: Most traded 250 stocks by 20-day turnover
- 500: Most traded 500 stocks by 20-day turnover
- 1000: Most traded 1000 stocks by 20-day turnover
- All: Every actively traded NSE equity

Tiers rank by 20-day average turnover, not by index membership: `top 100` is the hundred most traded stocks, and is not the NIFTY 100. `from fno` narrows a scan to the ~200 stocks with listed futures & options.

## Window functions

| Function | Returns |
|---|---|
| avg(x, n) | Mean of x over the last n bars. |
| max(x, n) | Highest value of x over the last n bars. |
| min(x, n) | Lowest value of x over the last n bars. |
| sum(x, n) | Total of x over the last n bars. |
| stdev(x, n) | Population standard deviation of x. |
| median(x, n) | Median of x over the last n bars. |

A window returns nothing until it is full. Periods take natural units — `avg(volume, 20)`, `max(high, 20 bars)`, `min(low, 52w)`, `median(close, 3mo)`.

## Time travel

| Written | Means |
|---|---|
| close | This bar — the scan date. |
| close[-1] | The previous bar. |
| prev close | The previous bar, spelled out. |
| close[-5] | Five bars ago. |
| avg(volume, 20)[-1] | The 20-bar average as of yesterday. |

Offsets are negative only. `close[1]` is rejected rather than read as the future — silently treating it as the past is how look-ahead bias gets into a scan.

## Operators

| Operators | Notes |
|---|---|
| > >= < <= = != | `=` is accepted as `==`. |
| + - * / | Division by zero yields no value rather than an error. |
| and  or  not | `and` binds tighter than `or`. Parenthesise when mixing. |
| ( ) | Grouping, for both conditions and arithmetic. |

Comparisons chain: `close > ema(21) > ema(50)` means each neighbouring pair must hold.

## Sugar

| Written | Equivalent to |
|---|---|
| 2x avg(volume, 20) | 2 * avg(volume, 20) |
| 5% above ema(50) | ema(50) * 1.05 |
| 3% below sma(200) | sma(200) * 0.97 |
| close within 2% of high_52w | close between high_52w*0.98 and high_52w*1.02 |
| price between 50 and 5000 | price >= 50 and price <= 5000 |
| close up 3% over 5 bars | (close - close[-5]) / close[-5] >= 0.03 |
| close down 2% over 5 bars | (close[-5] - close) / close[-5] >= 0.02 |

These are not approximations. Each form is checked against its longhand equivalent in the test suite and must select exactly the same stocks.

## Event operators

| Form | True when |
|---|---|
| x crosses above y | x is above y now and was at or below on the previous bar. |
| x crosses below y | x is below y now and was at or above on the previous bar. |
| x crossed above y within n bars | That crossing happened on any of the last n bars. |
| x has been above y for n bars | x was above y on every one of the last n bars. |
| x rising for n bars | x increased on each of the last n bars. |
| x falling for n bars | x decreased on each of the last n bars. |
| x is highest in n | No bar in the window has a higher x. |
| x is lowest in n | No bar in the window has a lower x. |


## Numbers and literals

| Written | Value |
|---|---|
| 1k | 1,000 |
| 5L | 5,00,000 — five lakh |
| 2.5m | 25,00,000 |
| 10cr | 10,00,00,000 — ten crore |
| 1b | 100,00,00,000 |
| ₹500 / $50 | 500 / 50 — the symbol is read and discarded |
| 20 bars / 52w / 3mo / 2y | A duration, converted to trading sessions |

Durations convert at roughly 5 sessions a week and 252 a year, so `52w` is 260 bars and `1y` is 252.

## Errors

| Written | Reported as |
|---|---|
| clos > 100 | Unknown field `clos` — Did you mean `close`? |
| sma > 100 | `sma` needs a period — Try `sma(5)`, `sma(10)`, `sma(20)`. |
| rsi(1000) > 50 | `rsi` period must be between 2 and 400 — e.g. `rsi(14)`. |
| close[1] > 100 | `[1]` looks like a future bar — write `[-1]` for one bar ago. |
| rsi(14) crosses 30 | `crosses` must be followed by `above` or `below`. |
| on 15m where close > 100 | Timeframe `15m` is not available — this dataset is end-of-day only. |
| pattern is wibble | Unknown pattern `wibble`. |
| macd().wibble > 0 | `macd()` has no sub-field `wibble` — Available: line, signal, hist. |

A query the compiler refuses comes back as HTTP 200 with `ok: false` — a syntax error is a result, not a server failure.

## Data caveats

| Caveat | The honest version |
|---|---|
| F&O coverage | Roughly 200 NSE stocks have listed derivatives. Everywhere else the F&O fields are NULL and never match — `from fno` makes the scope explicit. |
| Fundamentals coverage | The filings backfill is in progress; a stock without parsed results has NULL P/E and growth, and never matches those conditions. Coverage rises weekly. |
| Institutional holdings | Promoter and public shares of equity are filed every quarter and are the two the shareholding view is built on. FII, DII, employee-trust and pledge percentages come from a separate filing stage whose backfill has reached about 1% of instruments — they are NULL almost everywhere, including for the largest companies on the exchange, and never match. |
| Quarterly results | The per-quarter profit and loss starts in 2017 and the shareholding pattern in 2015. NSE's quarterly filings carry a P&L only, so there is no balance sheet, cash flow, debt or return-on-capital figure anywhere in this dataset. |
| Sector history | Classification is today's snapshot — NSE publishes no history. A historical scan or hit-rate replay applies the current sector retroactively. |
| OI units | Open interest is in contracts, summed across expiries, both before and after a lot-size revision — the unit NSE actually publishes. |

## Not supported

| Feature | Why not |
|---|---|
| on 15m / 1h / weekly | The dataset is end-of-day only. `on daily` is the only timeframe. |
| from BSE / US / NIFTY500 | NSE only, and there is no index-constituent list to filter by. `from fno` is the one list-like universe. |
| vwap | Needs intraday data, which end-of-day bars cannot provide. |
| per-strike option screening | F&O fields are per-stock daily aggregates. Strike-level OI is a chain view, not a screener column. |
| pattern is … forming | Geometric pattern detection with a confidence score is not built. Only completed candlestick patterns are available. |
| backtest { } / alert { } | Not implemented. The hit-rate panel on each scan is the nearest thing. |
| top 10% by … | Percentile limits are rejected; use a plain count. |

Rows with a glossary link have a full entry explaining the term — 48 of them, indexed at https://patternsradar.com/learn.md. Runnable examples live on the rendered page: https://patternsradar.com/docs/sift.
