Legacy-feed functions

27 functions

The compiler accepts all of these, but they are served by a China A-share style data feed. On the current market data source they return nothing, so a script that depends on them will draw an empty pane rather than fail.

DYNAINFO(N)legacy feed

Field N of the real-time quote snapshot — previous close, open, bid/ask and so on.

N(integer)
Which snapshot field to read — a field number, not a bar count.
// needs an A-share style feed — on the current data source
// this returns nothing and the pane stays empty
PREVCLOSE: DYNAINFO(3);
CHG: (CLOSE - PREVCLOSE) / PREVCLOSE * 100, COLORSTICK;
FINANCE(N)legacy feed

Financial statement field N for the symbol.

N(integer)
Which financial field to read.
// legacy feed only — returns nothing on the current source
EPS: FINANCE(33);
PE: CLOSE / EPS, COLORYELLOW;
FINVALUE(N)legacy feed

Financial field N as a time series.

N(integer)
Which financial field to read, as a series rather than one value.
// unlike FINANCE this varies bar by bar, so it can be
// charted directly — legacy feed only
BOOK: FINVALUE(34), COLORYELLOW;
FINONE(N, DATE, TYPE)legacy feed

A single financial field at a given reporting date.

N(integer)
Which financial field to read.
DATE(integer)
Reporting date, in the feed's date encoding.
TYPE(integer)
Which report type the figure comes from.
// a fixed reporting period rather than the latest —
// legacy feed only
Q1: FINONE(33, 250331, 0);
GPJYVALUE(A, B, C)legacy feed

Stock-level trading statistics series.

A(integer)
Statistic group.
B(integer)
Which statistic within the group.
C(integer)
Variant or sub-field of that statistic.

Also written as SCJYVALUE, BKJYVALUE

// SCJYVALUE and BKJYVALUE are the market and sector level
// equivalents — all three need the legacy feed
STAT: GPJYVALUE(1, 1, 0), COLORYELLOW;
GPJYONE(A, B, C, D)legacy feed

A single stock-level trading statistic.

A(integer)
Statistic group.
B(integer)
Which statistic within the group.
C(integer)
Variant or sub-field.
D(integer)
Which period the single value is taken from.

Also written as SCJYONE, BKJYONE

// the single-value counterpart of GPJYVALUE — legacy feed only
ONE: GPJYONE(1, 1, 0, 0);
MARGIN(N)legacy feed

Margin trading and short selling data.

N(integer)
Which margin field to read.
// rising margin balance alongside rising price is the
// classic leverage-driven advance — legacy feed only
BAL: MARGIN(1), COLORYELLOW;
LEVERAGED: BAL > REF(BAL, 5) AND CLOSE > REF(CLOSE, 5);
HK2SHSZ(N)legacy feed

Northbound Stock Connect holdings data.

N(integer)
Which Stock Connect field to read.
// northbound holdings as a sentiment proxy — legacy feed only
HOLD: HK2SHSZ(1), COLORYELLOW;
INFLOW: HOLD > REF(HOLD, 1);
NEWS(N)legacy feed

News and announcement analysis data.

N(integer)
Which news field to read.
// mark bars carrying an announcement — legacy feed only
HASNEWS := NEWS(1) > 0;
DRAWICON(HASNEWS, HIGH, 1);
UPCOUNT(INDEX)legacy feed

Number of advancing constituents in an index.

INDEX(string)
Index code whose constituents are counted.
// market breadth: advancing share of the index —
// legacy feed only
UP := UPCOUNT('000001');
DN := DOWNCOUNT('000001');
BREADTH: UP / (UP + DN) * 100, COLORYELLOW;
DOWNCOUNT(INDEX)legacy feed

Number of declining constituents in an index.

INDEX(string)
Index code whose constituents are counted.
// the advance-decline line, accumulated — legacy feed only
ADL: SUM(UPCOUNT('000001') - DOWNCOUNT('000001'), 0), COLORYELLOW;
SF(A, B, C)legacy feed

Sector-level financial aggregate.

A(integer)
Which sector aggregate group.
B(integer)
Which field within the group.
C(integer)
Variant or period selector.
// sector fundamentals rather than the symbol's own —
// legacy feed only
SECTORPE: SF(1, 1, 0), COLORYELLOW;
INBLOCK('NAME')legacy feed

1 if the symbol belongs to the named sector or concept block.

NAME(string)
Block name to test membership of.
// branch on sector membership — legacy feed only
ISBANK := INBLOCK('银行');
LEN := IF(ISBANK, 60, 20);
ADAPTED: MA(CLOSE, LEN), COLORYELLOW;
COST(N)legacy feed

Chip-distribution cost price at the N-th percentile of holders.

N(integer)
Percentile of holders, 0–100 — not a bar count.
// the chip distribution's quartiles as support bands —
// legacy feed only
C90: COST(90), COLORRED;
C50: COST(50), COLORYELLOW;
C10: COST(10), COLORGREEN;
COSTEX(A, B)legacy feed

Average cost of the chips between two price levels.

A(float)
Lower percentile bound.
B(float)
Upper percentile bound.
// average cost of the middle 80% of holders, ignoring the
// extremes at both ends — legacy feed only
CORE: COSTEX(10, 90), COLORYELLOW;
WINNER(PRICE)legacy feed

Fraction of holders in profit at PRICE.

PRICE(series)
Price to evaluate profitability against — usually CLOSE.
// share of holders sitting on a profit; a very high reading
// means everyone above is free to sell — legacy feed only
W: WINNER(CLOSE) * 100, COLORYELLOW;
CROWDED := W > 90;
PPART(N)legacy feed

Share of chips accumulated in the last N bars.

N(integer)
Window length in bars.
// how much of the float changed hands recently — legacy feed only
RECENT: PPART(20) * 100, COLORYELLOW;
TURNEDOVER := RECENT > 50;
LWINNER(N, PRICE)legacy feed

Profit ratio at PRICE counting only the last N bars.

N(integer)
How many recent bars to count.
PRICE(series)
Price to evaluate profitability against.
// split the profit ratio into new money and old money;
// PWINNER is the mirror image — legacy feed only
NEWMONEY: LWINNER(20, CLOSE) * 100, COLORYELLOW;
OLDMONEY: PWINNER(20, CLOSE) * 100, COLORGRAY;
PWINNER(N, PRICE)legacy feed

Profit ratio at PRICE counting only bars before the last N.

N(integer)
How many recent bars to EXCLUDE.
PRICE(series)
Price to evaluate profitability against.
// old money still in profit while new money is under water
// is a very different tape from the reverse — legacy feed only
OLD: PWINNER(20, CLOSE) * 100, COLORGRAY;
TRAPPED := OLD > 80 AND LWINNER(20, CLOSE) * 100 < 30;
ZTPRICE(CLOSE, RATE)legacy feed

Daily limit-up price given a previous close and a limit rate.

CLOSE(series)
The previous close the limit is calculated from.
RATE(float)
Limit rate — 0.1 for a 10% board.
// mark bars that reached the board — legacy feed only
LIMIT := ZTPRICE(REF(CLOSE, 1), 0.1);
DRAWICON(HIGH >= LIMIT, HIGH, 1), COLORRED;
DTPRICE(CLOSE, RATE)legacy feed

Daily limit-down price.

CLOSE(series)
The previous close the limit is calculated from.
RATE(float)
Limit rate — 0.1 for a 10% board.
// the down-side counterpart — legacy feed only
FLOOR := DTPRICE(REF(CLOSE, 1), 0.1);
DRAWICON(LOW <= FLOOR, LOW, 2), COLORGREEN;
CODELIKE('600')legacy feed

1 if the symbol code starts with the given prefix.

PREFIX(string)
Prefix to match at the START of the code — unlike FINDSTR, which matches anywhere.
// board-specific rules by code prefix — legacy feed only.
// FINDSTR(CODE, '600') works on the current feed and matches
// anywhere in the code, which is usually close enough
MAIN := CODELIKE('600');
NAMELIKE('BANK')legacy feed

1 if the symbol name starts with the given prefix.

PREFIX(string)
Prefix to match at the start of the name.

Also written as NAMEINCLUDE

// legacy feed only; FINDSTR(STKNAME, …) is the portable
// equivalent on the current data source
STFLAG := NAMELIKE('ST');
DRAWGBK(STFLAG, RGBA(239,83,80,0.10), RGBA(19,23,34,0), 90);
REFDATE(X, DATE)legacy feed

The value X had on a specific calendar date.

X(series)
The series to sample.
DATE(integer)
Calendar date to sample at — a date, not a bar offset like REF.
// anchor to a date rather than a bar count, so the reference
// survives holidays and suspensions — legacy feed only
BASE: REFDATE(CLOSE, 250101);
SINCE: (CLOSE - BASE) / BASE * 100, COLORYELLOW;
STKINDI(SYMBOL, 'INDEX.OUTPUT', PERIOD, RIGHT)legacy feed

Evaluate another indicator on another symbol or timeframe.

SYMBOL(string)
Symbol to evaluate on. Empty means the current one.
INDEX.OUTPUT(string)
Indicator name and output name, joined by a dot.
PERIOD(integer)
Timeframe code to evaluate on.
RIGHT(integer)
Adjustment mode: 0 none, 1 back-adjusted, 2 forward-adjusted.

Also written as CALCSTOCKINDEX

// cross-symbol reference — legacy feed only. On the current
// source, use Indicator.Output for same-symbol references,
// which inlines at compile time and costs nothing
OTHER: STKINDI('000001', 'MACD.DIF', 0, 0), COLORYELLOW;
LOADAPIDATA(…)legacy feed

Load a series from a configured external API endpoint.

…(string)
Endpoint and field selectors, as configured on the host.
// needs an endpoint configured on the host as well as the
// legacy feed — nothing to load on the current source
EXT: LOADAPIDATA('myfeed', 'value'), COLORYELLOW;
L2_VOL(N, M)legacy feed

Level-2 volume bucketed by order size N (0–3) and direction M (0–3).

N(integer)
Order-size bucket, 0–3 — small through extra large.
M(integer)
Direction bucket, 0–3.

Also written as L2_AMO, L2_VOLNUM

// large-order net flow — needs Level-2 data on top of the
// legacy feed, so it draws nothing on the current source
BIGBUY  := L2_VOL(3, 0);
BIGSELL := L2_VOL(3, 1);
NETBIG: BIGBUY - BIGSELL, COLORSTICK;