Tham chiếu hàm
- 🇻🇳 Tiếng Việt
- 🇬🇧 English
- 🇰🇷 한국어
- 🇨🇳 中文
Bảng tra mọi hàm của SDK Quant AI Studio. Trường dữ liệu của d ở Dữ liệu và Panel; khai báo chiến lược ở Chiến lược; bộ lọc, phân tích và đầu ra ở Bộ lọc và phân tích. Trong Studio, nút Tài liệu SDK ở tab Mã mở bản tóm tắt cùng nội dung.
Quy ước chung: x, y là Panel; ở phép tính Panel, y là một số hoặc một Panel (cùng hình, hoặc Panel một hàng như d.bench.close). Ô chưa đủ dữ liệu cho kết quả NaN.
Hàm toàn cục
| Hàm | Ý nghĩa |
|---|---|
strategy({…}) | Khai báo chiến lược backtest — Chiến lược |
screen({…}) | Khai báo bộ lọc — Bộ lọc |
research(async (ctx) => …) · research({ name, params, run }) | Khai báo phân tích — Phân tích |
universe(…) | Rổ mã — bên dưới |
param.* | Tham số — bên dưới |
ta.*, stats.*, dates.* | Chỉ báo, thống kê, ngày — bên dưới |
log(…giáTrị) | In ra Nhật ký chạy (Panel in tóm tắt: số mã × số phiên, giá trị phiên cuối); console.log cũng vậy |
byYearMonth(panelTháng, hàng = 0) | Bảng năm × tháng { xLabels: ["T1"…"T12"], yLabels: [năm], values } cho chart.heatmap; Panel theo phiên thì lấy giá trị cuối tháng |
monthOfYearMean(panelTháng, hàng = 0) | Thống kê theo tháng trong năm: [{ month, mean, count, positive }] (positive: tỷ lệ năm dương) |
Panel | Dựng Panel — Tự dựng Panel |
Tham số: param.*
| Hàm | Trên thanh tham số | Giá trị p.tên |
|---|---|---|
param.int(14, { min, max, step, label }) | Thanh trượt số nguyên (bước 1) | số nguyên |
param.num(1.5, { min, max, step, label }) | Thanh trượt số thực (bước mặc định 1 khi giá trị ≥ 10, còn lại 0,1) | số |
param.pct(0.07, { min, max, step, label }) | Thanh trượt hiện %, bước 0,5% | tỷ lệ (0,07 = 7%) |
param.bool(true, { label }) | Công tắc Bật / Tắt | true / false |
param.choice("Momentum 6-1", ["Momentum 6-1", "Biến động thấp"], { label }) | Ô chọn | phần tử được chọn (chuỗi hoặc số) |
param.symbol("FPT", { label: "Mã" }) | Ô nhập mã (Enter hoặc rời ô để chạy; Esc huỷ) | mã chữ hoa: cổ phiếu, chỉ số, ETF, chỉ số thế giới (^GSPC) |
labellà chữ hiện trên thanh tham số — đặt tiếng Việt ngắn. Thiếumin/max: thanhpctchạy 0 → max(50%, 3 lần mặc định);int,numchạy quanh giá trị mặc định.- Giá trị ngoài
[min, max]bị kẹp lại;intlàm tròn;choicekhông có trong danh sách về mặc định; mã sai định dạng về mặc định. - Khai báo gọn bằng giá trị trần cũng được:
params: { len: 14, ratio: 1.5, useStop: true }(số nguyên →int, số thực →num, đúng / sai →bool). - Đổi tham số trên giao diện chạy lại ngay, không tạo phiên bản mới; nút Mặc định đưa về giá trị trong code. Tối ưu tham số quét trong khoảng
min–max(Tối ưu và kiểm định độ vững).
Rổ mã: universe(…)
| Cách viết | Gồm |
|---|---|
universe("ALL") | Cổ phiếu mã 3 ký tự trên HOSE, HNX, UPCoM (1.519 mã ngày 19/10/2026). Backtest: theo thời điểm |
universe("HOSE"), "HNX", "UPCOM" | Cổ phiếu từng sàn. Backtest HOSE: theo thời điểm (từ 09/2016) |
universe("VN30"), "HNX30" | Thành phần hiện tại của rổ chỉ số |
universe("VN100"), "VNMID", "VNSML" | Thành phần theo danh sách cũ của nguồn — không nên dùng (vì sao) |
universe("ETF") | Chứng chỉ quỹ ETF niêm yết (E1VFVN30, FUEVFVND…) |
universe("INDEX") | Chỉ số: VNINDEX, VN30, HNX-Index, HNX30, UPCoM-Index và các chỉ số thế giới (^GSPC, ^IXIC, ^N225…) |
universe("FUTURES") | Hợp đồng tương lai VN30, VN100 |
universe(["FPT", "HPG"]), universe("FPT,HPG") | Danh sách mã tự chọn |
universe({ industry: "Ngân hàng" }) | Theo ngành: mọi mã có tên ngành (hoặc nhóm ngành) chứa chữ đó, không phân biệt dấu; số → mã ICB bắt đầu bằng số đó. Backtest: theo thời điểm |
universe({ watchlist: "Tên" }) | Watchlist của bạn theo tên (cần đăng nhập; không tìm thấy: Không tìm thấy watchlist "…") |
Nối thêm điều kiện (tên rổ không phân biệt hoa thường):
| Phương thức | Ý nghĩa |
|---|---|
.liquid(5e9) | GTGD bình quân 20 phiên từ 5 tỷ. Backtest: xét ở từng phiên; bộ lọc: ở phiên lọc; phân tích: chỉ lọc thô (GTGD hiện tại từ 20% ngưỡng). Mặc định 5 tỷ |
.exchange("HOSE", "HNX") | Chỉ các sàn này |
.industry("Ngân hàng", "Bảo hiểm") | Chỉ các ngành này (khớp như { industry }) |
.exclude(["ROS", "FLC"]) · .exclude({ exchange: "UPCOM" }) | Bỏ mã / bỏ một sàn |
.include(["VNM"]) | Thêm mã (kể cả ngoài rổ) |
.minPrice(5) | Giá hiện tại từ 5 nghìn đồng |
.top(100) | 100 mã thanh khoản nhất: GTGD 20 phiên hiện tại; rổ theo thời điểm khi backtest: GTGD bình quân trong kỳ |
.where((m) => m.marketCap > 1e13) | Điều kiện tự viết trên thông tin mã hiện tại (m.exchange là "HSX" với HOSE) |
Rổ chung vượt giới hạn số mã của gói thì giữ các mã thanh khoản nhất; danh sách tự chọn, watchlist vượt giới hạn thì báo lỗi (Giới hạn số mã).
Chỉ báo: ta.*
Đầu vào giá là Panel (d.close); chỉ báo cần cao, thấp, đóng cửa nhận cả đối tượng d (hoặc d.bench cho VNINDEX). RSI, ATR, ADX làm trơn kiểu Wilder như chỉ báo trên bảng giá FireAnt.
| Hàm | Trả về | Cách tính |
|---|---|---|
ta.sma(x, n = 20) | Panel | Trung bình n phiên |
ta.ema(x, n = 20) | Panel | Trung bình hàm mũ, α = 2 ÷ (n + 1), khởi đầu bằng SMA n giá trị đầu |
ta.wma(x, n = 20) | Panel | Trung bình trọng số 1, 2…n (mới nhất nặng nhất) |
ta.hma(x, n = 20) | Panel | Hull: WMA(2 × WMA(n/2) − WMA(n), √n) |
ta.rma(x, n = 14) | Panel | Làm trơn Wilder: (trước × (n − 1) + x) ÷ n |
ta.rsi(x, n = 14) | Panel 0–100 | RSI = 100 − 100 ÷ (1 + RS), RS = trung bình tăng ÷ trung bình giảm (Wilder) |
ta.macd(x, 12, 26, 9) | { macd, signal, hist } | macd = EMA12 − EMA26; signal = EMA9 của macd; hist = macd − signal |
ta.bb(x, 20, 2) | { mid, upper, lower, pctB, width } | mid = SMA20; dải = mid ± 2σ (độ lệch chuẩn tổng thể); %B = (x − dưới) ÷ (trên − dưới); width = (trên − dưới) ÷ mid |
ta.atr(d, 14) | Panel | RMA của true range = max(cao − thấp, |cao − đóng cửa trước|, |thấp − đóng cửa trước|) |
ta.adx(d, 14) | { adx, plusDI, minusDI } | ±DI = 100 × RMA(±DM) ÷ ATR; ADX = RMA của 100 × |+DI − −DI| ÷ (+DI + −DI) |
ta.stoch(d, 14, 3, 3) | { k, d } | %K = 100 × (đóng cửa − thấp nhất 14) ÷ (cao nhất 14 − thấp nhất 14), làm trơn SMA 3; %D = SMA 3 của %K |
ta.cci(d, 20) | Panel | (TP − SMA(TP)) ÷ (0,015 × độ lệch tuyệt đối bình quân), TP = (cao + thấp + đóng cửa) ÷ 3 |
ta.mfi(d, 14) | Panel 0–100 | Money Flow Index: 100 − 100 ÷ (1 + dòng tiền dương ÷ dòng tiền âm), dòng tiền = TP × KL |
ta.obv(d) | Panel | On-Balance Volume: cộng KL phiên tăng, trừ KL phiên giảm |
ta.vwap(d, 20) | Panel | VWAP trượt 20 phiên: Σ(TP × KL) ÷ ΣKL |
ta.donchian(d, 20) | { upper, lower, mid } | Cao nhất / thấp nhất 20 phiên và trung điểm |
ta.keltner(d, 20, 2, 10) | { upper, lower, mid } | mid = EMA20 giá đóng cửa; dải = mid ± 2 × ATR10 |
ta.supertrend(d, 10, 3) | { line, dir } | Dải (cao + thấp) ÷ 2 ± 3 × ATR10; dir = 1 xu hướng tăng, −1 giảm |
ta.psar(d, 0.02, 0.2) | Panel | Parabolic SAR, bước 0,02, tối đa 0,2 |
ta.roc(x, 12) | Panel (%) | 100 × (x ÷ x 12 phiên trước − 1) |
ta.williamsR(d, 14) | Panel −100–0 | −100 × (cao nhất 14 − đóng cửa) ÷ (cao nhất 14 − thấp nhất 14) |
ta.ichimoku(d, 9, 26, 52) | { tenkan, kijun, spanA, spanB } | tenkan, kijun = trung điểm cao – thấp 9, 26 phiên; spanA = (tenkan + kijun) ÷ 2; spanB = trung điểm 52 phiên. Chưa dịch về phía trước: mây vẽ trên biểu đồ ở phiên t là spanA.shift(26), spanB.shift(26) |
ta.slope(x, 20) | Panel | Độ dốc hồi quy tuyến tính 20 phiên (đơn vị giá mỗi phiên) |
ta.trueRange(high, low, close), ta.typicalPrice(high, low, close) | Panel | True range; giá điển hình (cao + thấp + đóng cửa) ÷ 3 |
ta.atr, adx, stoch, cci, mfi, williamsR, donchian cũng nhận Panel riêng: ta.atr(d.high, d.low, d.close, 14) (mfi thêm Panel KL: ta.mfi(d.high, d.low, d.close, d.volume, 14); donchian chỉ cần cao, thấp: ta.donchian(d.high, d.low, 20)).
Mẫu hình giá: ta.patterns
ta.patterns(d, { th, only, minVol, near, recent }) nhận diện 8 mẫu hình kinh điển trên mọi mã của d, không nhìn trước: đỉnh, đáy theo ZigZag chỉ được biết khi giá đã quay đầu đủ ngưỡng; phá vỡ là phiên đầu tiên giá đóng cửa vượt mức của mẫu (mẫu giảm giá: thủng), mỗi mẫu một lần. Mẫu dài tới 250 phiên — bộ lọc nên đặt lookback: 500.
| Tuỳ chọn | Ý nghĩa | Mặc định |
|---|---|---|
th | Ngưỡng ZigZag xác nhận đỉnh / đáy | 0.08 |
only | Các mẫu cần quét: "cup" (cốc tay cầm), "doubleBottom" (hai đáy W), "ascTriangle" (tam giác tăng), "invHeadShoulders" (vai đầu vai ngược), "flag" (cờ tăng), "vcp" (nền co hẹp dần), "doubleTop" (hai đỉnh M), "headShoulders" (vai đầu vai) | tất cả |
minVol | Mẫu tăng giá: phá vỡ chỉ tính khi KL phiên phá vỡ ≥ minVol × TB 20 phiên trước (mẫu giảm giá không cần KL) | 1.5 |
near | "Sát điểm phá vỡ": đóng cửa còn dưới mức, cách tối đa near | 0.05 |
recent | "Vừa phá vỡ": phá vỡ trong recent phiên gần nhất và giá vẫn ở phía bên kia mức | 5 |
| Trả về | Nội dung |
|---|---|
breakout | Panel: 1 ở phiên phá vỡ đủ khối lượng (mẫu giảm: phiên thủng), 0 còn lại — dùng làm entry của chiến lược |
pattern, names | Panel mã số mẫu hình đang có ở từng phiên (NaN khi không có) và mảng tên theo mã số |
stage, stages | Panel 0 không có, 1 sát điểm phá vỡ, 2 vừa phá vỡ; mảng tên trạng thái |
level, distance | Mức phá vỡ của mẫu đang có; đóng cửa ÷ mức − 1 (âm là còn dưới mức) |
since, volRatio | Số phiên từ khi phá vỡ; KL phiên phá vỡ ÷ TB20 (khi vừa phá vỡ) |
events | Mọi lần phá vỡ / thủng: { symbol, row, t, day, pattern, name, bullish, level, volRatio, start } — để nghiên cứu sự kiện |
Mã số trong pattern theo thứ tự cup (0), doubleBottom (1), ascTriangle (2), invHeadShoulders (3), flag (4), vcp (5), doubleTop (6), headShoulders (7) — tức names[k]. Một mã có nhiều mẫu cùng lúc thì pattern, stage lấy mẫu có trạng thái cao hơn (vừa phá vỡ trước sát điểm phá vỡ). ta.PATTERNS là bảng thông tin từng mẫu theo khoá: { name, bullish, level } (tên, mẫu tăng giá hay không, tên mức phá vỡ như "miệng cốc", "đỉnh giữa") — dùng khi tự nghiên cứu events.
| Mẫu | Hình học (đỉnh, đáy ZigZag đã xác nhận) | Mức phá vỡ |
|---|---|---|
cup | Cốc sâu 12–50%, hai miệng lệch nhau không quá 8%, dài 25–250 phiên; tay cầm điều chỉnh không quá 18%, ở nửa trên của cốc, trong 40 phiên | Miệng cốc (miệng phải) |
doubleBottom | Hai đáy lệch không quá 5%, cách nhau 15–150 phiên; đỉnh giữa cao hơn hai đáy từ 10% | Đỉnh giữa |
ascTriangle | Hai đỉnh lệch không quá 3%; đáy sau cao hơn đáy trước từ 3%; 15–150 phiên | Đỉnh cao hơn trong hai đỉnh |
invHeadShoulders | Đầu thấp hơn hai vai từ 3%; hai vai lệch không quá 10%; 20–180 phiên | Đường viền cổ nối hai đỉnh (có thể nghiêng) |
flag | Cán cờ tăng từ 20% trong tối đa 25 phiên; điều chỉnh không quá nửa cán, trong tối đa 20 phiên | Đỉnh cán cờ |
vcp | Ba nhịp điều chỉnh nhỏ dần (nhịp đầu từ 12%, nhịp cuối không quá 12%), các đỉnh lệch không quá 10%, 25–250 phiên, giá trên giá 200 phiên trước | Đỉnh nhịp cuối |
doubleTop | Hai đỉnh lệch không quá 5%, cách nhau 15–150 phiên; đáy giữa thấp hơn hai đỉnh từ 10% | Đáy giữa (thủng xuống) |
headShoulders | Đầu cao hơn hai vai từ 3%; hai vai lệch không quá 10%; 20–180 phiên | Đường viền cổ nối hai đáy (thủng xuống) |
ta.zigzag(d, 0.08) trả đỉnh / đáy ZigZag của từng mã: mảng theo hàng, mỗi phần tử { i, price, kind, at } (kind 1 là đỉnh, −1 là đáy; i là phiên của đỉnh / đáy, at là phiên nó được xác nhận — luôn sau i). Ví dụ dùng trong chiến lược, bộ lọc: mua khi phá vỡ mẫu hình, bộ lọc có cột chữ; code đầy đủ của các mẫu nhóm Mẫu hình (Danh sách mẫu) ở tab Mã khi mở mẫu.
Phép tính Panel
Số học — trả Panel mới; NaN lan theo phép tính.
| Hàm | Ý nghĩa |
|---|---|
add(y) sub(y) mul(y) div(y) | Cộng, trừ, nhân, chia; chia cho 0 → NaN |
pow(y) | Luỹ thừa |
min(y) max(y) | Nhỏ hơn / lớn hơn từng phần tử (một bên NaN → NaN) |
neg() abs() sign() | Đổi dấu, trị tuyệt đối, dấu (−1 / 0 / 1) |
log() exp() sqrt() | Logarit tự nhiên (≤ 0 → NaN), mũ, căn (< 0 → NaN) |
round(chữSố = 0) clip(dưới, trên) | Làm tròn, kẹp trong khoảng |
map(fn) | Áp hàm tự viết lên từng phần tử |
So sánh và logic — kết quả 1 / 0 / NaN.
| Hàm | Ý nghĩa |
|---|---|
gt gte lt lte eq neq | >, ≥, <, ≤, =, ≠ |
between(dưới, trên) | Trong khoảng, gồm hai đầu |
and(y) or(y) not() | Logic ba trạng thái: 0 and NaN = 0, 1 or NaN = 1 |
where(điềuKiện, khác = NaN) | Giữ giá trị khi điều kiện đúng, ngược lại lấy khác (số hoặc Panel) |
isNaN() notNaN() | 1 nếu thiếu / có dữ liệu |
fillna(v) | Thay NaN bằng v |
ffill(giớiHạn?) | Điền tiếp giá trị gần nhất trước đó, tối đa n phiên |
Theo thời gian — tính riêng từng mã, chỉ dùng quá khứ.
| Hàm | Ý nghĩa |
|---|---|
shift(n = 1) | Giá trị n phiên trước (n ≥ 0; số âm báo lỗi nhìn trước) |
diff(n = 1) | x − x n phiên trước |
pct(n = 1) | x ÷ x n phiên trước − 1 |
cumsum() cumprod() cummax() cummin() | Luỹ kế từ giá trị đầu tiên có số |
ewm(span) | Trung bình hàm mũ (như ta.ema) |
highest(n) lowest(n) | Lớn nhất / nhỏ nhất n phiên gần nhất (gồm phiên hiện tại) |
crossAbove(y) | 1 ở phiên cắt lên: phiên trước ≤ y, phiên này > y |
crossBelow(y) | 1 ở phiên cắt xuống: phiên trước ≥ y, phiên này < y |
barsSince() | Số phiên từ lần gần nhất điều kiện đúng (0 ở chính phiên đó; chưa từng đúng → NaN) |
hold(n) | Giữ trạng thái đúng thêm n phiên sau mỗi lần đúng |
Cửa sổ trượt — x.rolling(n).…: cần đủ n giá trị liên tiếp không NaN.
| Hàm | Ý nghĩa |
|---|---|
.mean() .sum() | Trung bình, tổng n phiên |
.std(mẫu = false) .var(mẫu = false) | Độ lệch chuẩn, phương sai (mặc định chia n; true chia n − 1) |
.min() .max() | Nhỏ nhất, lớn nhất |
.count() | Số giá trị có số trong n phiên (không cần đủ n) |
.rank() | Vị trí của giá trị hiện tại trong n phiên, 0 (thấp nhất) → 1 (cao nhất) |
.zscore() | (x − trung bình n phiên) ÷ độ lệch chuẩn n phiên |
Cắt ngang — so giữa các mã trong từng phiên (bỏ mã NaN).
| Hàm | Ý nghĩa |
|---|---|
rank() | Hạng phần trăm: 0 = thấp nhất, 1 = cao nhất; bằng nhau lấy hạng trung bình |
zscore() demean() | Chuẩn hoá theo trung bình, độ lệch chuẩn của các mã; trừ trung bình |
bucket(q) | Nhóm phân vị 1…q (q = 5: ngũ phân vị, 5 = cao nhất) |
topN(n) bottomN(n) | 1 cho n mã lớn / nhỏ nhất mỗi phiên, 0 cho mã khác |
sumAcross() meanAcross() countAcross() | Tổng, trung bình, số mã có số — Panel một hàng |
mean() | Một số: trung bình toàn bộ Panel (chỉ dùng trong phân tích) |
Lấy giá trị, cắt, đổi tần suất
| Hàm | Ý nghĩa |
|---|---|
last(t?) | Row giá trị phiên cuối (hoặc phiên thứ t) của từng mã: .get("FPT"), .values, .toObject(), .truthySymbols() (mã có giá trị đúng) |
at(ngày) | Row ở phiên gần nhất trước hoặc bằng ngày (số ngày, xem dates.parse) |
values("FPT") · row(i) · get(i, t) | Mảng giá trị một mã (bản sao) · mảng của hàng thứ i · một ô |
pick(["FPT", "HPG"]) · range(từNgày, đếnNgày) · sliceCols(từ, đến) | Chọn mã · cắt theo ngày · cắt theo chỉ số phiên |
symbols days rows cols | Danh sách mã, ngày các phiên, số hàng, số phiên |
resample("week" | "month" | "quarter" | "year") + .last() .first() .sum() .mean() .max() .min() | Gộp theo tuần (bắt đầu thứ Hai), tháng, quý, năm; ngày của mỗi kỳ là phiên cuối kỳ (kỳ đang dở: phiên mới nhất) |
Dựng Panel: Panel.fromRows(tênHàng, ngày, mảngCácHàng), Panel.full(tênHàng, ngày, giáTrị) — ví dụ.
Thống kê: stats.*
Nhận mảng số (hoặc Float32Array từ row(i), values(…)), bỏ qua NaN.
| Hàm | Ý nghĩa |
|---|---|
stats.mean(a) stats.median(a) | Trung bình, trung vị |
stats.std(a) stats.variance(a) | Độ lệch chu ẩn, phương sai mẫu (chia n − 1) |
stats.quantile(a, q) | Phân vị q (0–1), nội suy tuyến tính |
stats.skew(a) stats.kurtosis(a) | Độ lệch; độ nhọn (phân phối chuẩn = 3, không trừ 3) |
stats.corr(a, b) stats.cov(a, b) | Tương quan, hiệp phương sai (chỉ các cặp cùng có số) |
stats.linreg(x, y) | Hồi quy y = intercept + slope × x → { slope, intercept, r2 } |
stats.tstat(a) | Trung bình ÷ sai số chuẩn; trị tuyệt đối trên 2 ≈ có ý nghĩa thống kê |
stats.sharpe(lợiNhuậnPhiên, 250) | Sharpe năm hoá = trung bình ÷ độ lệch chuẩn × √250 (lãi suất phi rủi ro 0) |
stats.returns(chuỗiGiá) | Lợi nhuận từng phiên (dài hơn kém 1 phần tử) |
stats.drawdown(chuỗiGiá) | Mức giảm từ đỉnh tại từng điểm (≤ 0) |
stats.maxDrawdown(chuỗiGiá) | Sụt giảm tối đa (số âm). Chuỗi có ô NaN (mã niêm yết sau đầu kỳ) cho NaN — khi đó lấy giá trị nhỏ nhất của stats.drawdown(…) |
stats.drawdowns(chuỗiGiá, d.days, 10) | Các đợt sụt giảm sâu nhất: { peakDay, troughDay, recoveryDay, depth, toTrough, toRecover } (recoveryDay NaN nếu chưa hồi phục) |
stats.forward(chuỗiGiá, h) | Lợi nhuận h phiên kế tiếp tại từng điểm — chỉ để nghiên cứu sự kiện, không làm tín hiệu |
stats.hist(a, 30, [dưới, trên]?) | { edges, counts } của phân phối |
stats.normCdf(x) stats.normInv(p) | Hàm phân phối chuẩn tắc và hàm ngược |
Ngày: dates.*
Ngày trong SDK là số ngày kể từ 01/01/1970 (d.days[t], peakDay…).
| Hàm | Ý nghĩa |
|---|---|
dates.parse("2020-01-15") | Chuỗi → số ngày; nhận "2020-01-15", "2020", "15/01/2020" |
dates.format(ngày) | Số ngày → "15/01/2020" (để hiển thị) |
dates.iso(ngày) | Số ngày → "2020-01-15" |
dates.year(ngày) dates.month(ngày) dates.day(ngày) | Năm; tháng 1–12; ngày 1–31 |
dates.weekday(ngày) | 0 = Chủ nhật, 1 = thứ Hai … 6 = thứ Bảy |
dates.today() | Hôm nay (số ngày) |
Định dạng giá trị
Dùng trong format của cột bộ lọc, metric, biểu đồ, bảng.
| Định dạng | Hiển thị |
|---|---|
"percent" | Nhân 100, 2 chữ số thập phân: 0,0523 → 5.23% |
"price" | 2 ch ữ số thập phân (giá nghìn đồng): 57.30 |
"compact" | Rút gọn tiền: 12.50 tỷ, 45.30 tr (từ 100 trở lên bỏ số lẻ: 350 tr, 1,250 tỷ) |
"integer" | Số nguyên có dấu phẩy nhóm nghìn |
"ratio" | 2 chữ số thập phân (hệ số, P/E, Sharpe) |
"number" | Tự chọn số chữ số thập phân theo độ lớn |
"date" | Số ngày → dd/mm/yyyy |
"text" | Giữ nguyên chữ |
Số hiển thị theo quy ước của app: dấu phẩy nhóm nghìn, dấu chấm thập phân.
Tóm tắt khai báo
| Khai báo | Trường | Xem |
|---|---|---|
strategy | name description universe period benchmark warmup params · signals | rank + select | weights · rebalance filter · portfolio risk execution costs rules · report | Chiến lược |
screen | name universe params columns filter sort limit lookback asOf includeToday | Bộ lọc |
research | name params run(ctx, p) — ctx: data.bars data.symbols metric chart table md log params | Phân tích |
A lookup table of every function in the Quant AI Studio SDK. The data fields of d are in Data and Panel; strategy declarations in Strategy; screeners, analyses and outputs in Screeners and analyses. In Studio, the Tài liệu SDK (SDK docs) button in the Mã (Code) tab opens a summary of the same content.
General conventions: x, y are Panels; in Panel operations, y is a number or a Panel (of the same shape, or a single-row Panel such as d.bench.close). Cells without enough data yield NaN.
Global functions
| Function | Meaning |
|---|---|
strategy({…}) | Declare a backtest strategy — Strategy |
screen({…}) | Declare a screener — Screener |
research(async (ctx) => …) · research({ name, params, run }) | Declare an analysis — Analysis |
universe(…) | Ticker universe — below |
param.* | Parameters — below |
ta.*, stats.*, dates.* | Indicators, statistics, dates — below |
log(…giáTrị) | Print to the Nhật ký chạy (Run log) (a Panel prints as a summary: tickers × sessions, last-session values); console.log does the same |
byYearMonth(panelTháng, hàng = 0) | A year × month table { xLabels: ["T1"…"T12"], yLabels: [năm], values } for chart.heatmap; for a per-session Panel it takes the month-end value |
monthOfYearMean(panelTháng, hàng = 0) | Statistics by month of the year: [{ month, mean, count, positive }] (positive: share of positive years) |
Panel | Build a Panel — Building your own Panel |
Parameters: param.*
| Function | On the parameter bar | Value of p.tên |
|---|---|---|
param.int(14, { min, max, step, label }) | Integer slider (step 1) | integer |
param.num(1.5, { min, max, step, label }) | Decimal slider (default step 1 when the value is ≥ 10, otherwise 0.1) | number |
param.pct(0.07, { min, max, step, label }) | Slider showing %, step 0.5% | ratio (0.07 = 7%) |
param.bool(true, { label }) | A Bật / Tắt (On / Off) toggle | true / false |
param.choice("Momentum 6-1", ["Momentum 6-1", "Biến động thấp"], { label }) | Dropdown | the selected element (string or number) |
param.symbol("FPT", { label: "Mã" }) | Ticker input (Enter or leaving the field runs it; Esc cancels) | uppercase ticker: stock, index, ETF, world index (^GSPC) |
labelis the text shown on the parameter bar — use short Vietnamese. Withoutmin/max: apctslider runs from 0 → max(50%, 3 times the default);intandnumrun around the default value.- Values outside
[min, max]are clamped;intis rounded; achoicenot in the list falls back to the default; a malformed ticker falls back to the default. - A short declaration with bare values also works:
params: { len: 14, ratio: 1.5, useStop: true }(integer →int, decimal →num, true / false →bool). - Changing a parameter in the interface reruns immediately without creating a new version; the Mặc định (Default) button restores the value in the code. Parameter optimization scans within the
min–maxrange (Optimization and robustness validation).
Ticker universe: universe(…)
| Syntax | Includes |
|---|---|
universe("ALL") | Stocks with 3-letter tickers on HOSE, HNX, UPCoM (1,519 tickers on 19 Oct 2026). Backtest: point in time |
universe("HOSE"), "HNX", "UPCOM" | Stocks on each exchange. HOSE backtest: point in time (from Sep 2016) |
universe("VN30"), "HNX30" | Current constituents of the index basket |
universe("VN100"), "VNMID", "VNSML" | Constituents per the source's old list — not recommended (why) |
universe("ETF") | Listed ETF certificates (E1VFVN30, FUEVFVND…) |
universe("INDEX") | Indices: VNINDEX, VN30, HNX-Index, HNX30, UPCoM-Index and world indices (^GSPC, ^IXIC, ^N225…) |
universe("FUTURES") | VN30 and VN100 futures |
universe(["FPT", "HPG"]), universe("FPT,HPG") | A custom ticker list |
universe({ industry: "Ngân hàng" }) | By industry: every ticker whose industry name (or sector group) contains that text, accent-insensitive; a number → ICB codes starting with that number. Backtest: point in time |
universe({ watchlist: "Tên" }) | Your watchlist by name (requires sign-in; if not found: Không tìm thấy watchlist "…" (Watchlist "…" not found)) |
Chain further conditions (universe names are case-insensitive):
| Method | Meaning |
|---|---|
.liquid(5e9) | 20-session average trading value of at least VND 5 bn. Backtest: evaluated at each session; screener: at the screening session; analysis: rough filter only (current trading value at least 20% of the threshold). Default VND 5 bn |
.exchange("HOSE", "HNX") | Only these exchanges |
.industry("Ngân hàng", "Bảo hiểm") | Only these industries (matched like { industry }) |
.exclude(["ROS", "FLC"]) · .exclude({ exchange: "UPCOM" }) | Remove tickers / remove an exchange |
.include(["VNM"]) | Add tickers (even outside the universe) |
.minPrice(5) | Current price of at least VND 5 thousand |
.top(100) | The 100 most liquid tickers: current 20-session trading value; point-in-time universes in backtests: average trading value over the period |
.where((m) => m.marketCap > 1e13) | Custom condition on current ticker information (m.exchange is "HSX" for HOSE) |
A general universe that exceeds your plan's ticker limit keeps the most liquid tickers; a custom list or watchlist that exceeds the limit raises an error (Ticker limit).
Indicators: ta.*
Price inputs are Panels (d.close); indicators that need high, low and close take the whole d object (or d.bench for VNINDEX). RSI, ATR and ADX use Wilder smoothing, like the indicators on the FireAnt price board.
| Function | Returns | Calculation |
|---|---|---|
ta.sma(x, n = 20) | Panel | n-session average |
ta.ema(x, n = 20) | Panel | Exponential average, α = 2 ÷ (n + 1), seeded with the SMA of the first n values |
ta.wma(x, n = 20) | Panel | Weighted average with weights 1, 2…n (most recent heaviest) |
ta.hma(x, n = 20) | Panel | Hull: WMA(2 × WMA(n/2) − WMA(n), √n) |
ta.rma(x, n = 14) | Panel | Wilder smoothing: (previous × (n − 1) + x) ÷ n |
ta.rsi(x, n = 14) | Panel 0–100 | RSI = 100 − 100 ÷ (1 + RS), RS = average gain ÷ average loss (Wilder) |
ta.macd(x, 12, 26, 9) | { macd, signal, hist } | macd = EMA12 − EMA26; signal = EMA9 of macd; hist = macd − signal |
ta.bb(x, 20, 2) | { mid, upper, lower, pctB, width } | mid = SMA20; bands = mid ± 2σ (population standard deviation); %B = (x − lower) ÷ (upper − lower); width = (upper − lower) ÷ mid |
ta.atr(d, 14) | Panel | RMA of true range = max(high − low, |high − previous close|, |low − previous close|) |
ta.adx(d, 14) | { adx, plusDI, minusDI } | ±DI = 100 × RMA(±DM) ÷ ATR; ADX = RMA of 100 × |+DI − −DI| ÷ (+DI + −DI) |
ta.stoch(d, 14, 3, 3) | { k, d } | %K = 100 × (close − 14-period low) ÷ (14-period high − 14-period low), smoothed with SMA 3; %D = SMA 3 of %K |
ta.cci(d, 20) | Panel | (TP − SMA(TP)) ÷ (0.015 × mean absolute deviation), TP = (high + low + close) ÷ 3 |
ta.mfi(d, 14) | Panel 0–100 | Money Flow Index: 100 − 100 ÷ (1 + positive money flow ÷ negative money flow), money flow = TP × Vol |
ta.obv(d) | Panel | On-Balance Volume: add volume on up sessions, subtract volume on down sessions |
ta.vwap(d, 20) | Panel | Rolling 20-session VWAP: Σ(TP × Vol) ÷ ΣVol |
ta.donchian(d, 20) | { upper, lower, mid } | 20-session highest / lowest and the midpoint |
ta.keltner(d, 20, 2, 10) | { upper, lower, mid } | mid = EMA20 of the close; bands = mid ± 2 × ATR10 |
ta.supertrend(d, 10, 3) | { line, dir } | Bands (high + low) ÷ 2 ± 3 × ATR10; dir = 1 uptrend, −1 downtrend |
ta.psar(d, 0.02, 0.2) | Panel | Parabolic SAR, step 0.02, maximum 0.2 |
ta.roc(x, 12) | Panel (%) | 100 × (x ÷ x 12 sessions earlier − 1) |
ta.williamsR(d, 14) | Panel −100–0 | −100 × (14-period high − close) ÷ (14-period high − 14-period low) |
ta.ichimoku(d, 9, 26, 52) | { tenkan, kijun, spanA, spanB } | tenkan, kijun = midpoint of high – low over 9, 26 sessions; spanA = (tenkan + kijun) ÷ 2; spanB = 52-session midpoint. Not shifted forward: the cloud drawn on the chart at session t is spanA.shift(26), spanB.shift(26) |
ta.slope(x, 20) | Panel | 20-session linear regression slope (price units per session) |
ta.trueRange(high, low, close), ta.typicalPrice(high, low, close) | Panel | True range; typical price (high + low + close) ÷ 3 |
ta.atr, adx, stoch, cci, mfi, williamsR and donchian also accept separate Panels: ta.atr(d.high, d.low, d.close, 14) (mfi adds a volume Panel: ta.mfi(d.high, d.low, d.close, d.volume, 14); donchian only needs high and low: ta.donchian(d.high, d.low, 20)).
Price patterns: ta.patterns
ta.patterns(d, { th, only, minVol, near, recent }) detects 8 classic patterns on every ticker in d, without look-ahead: ZigZag peaks and troughs are only known once the price has reversed by the threshold; a breakout is the first session the close moves past the pattern's level (bearish patterns: a breakdown), once per pattern. Patterns can be up to 250 sessions long — screeners should set lookback: 500.
| Option | Meaning | Default |
|---|---|---|
th | ZigZag threshold to confirm a peak / trough | 0.08 |
only | Patterns to scan: "cup" (cup with handle), "doubleBottom" (W double bottom), "ascTriangle" (ascending triangle), "invHeadShoulders" (inverse head and shoulders), "flag" (bull flag), "vcp" (volatility contraction pattern), "doubleTop" (M double top), "headShoulders" (head and shoulders) | all |
minVol | Bullish patterns: a breakout only counts when breakout-session volume ≥ minVol × the previous 20-session average (bearish patterns need no volume) | 1.5 |
near | "Near breakout": the close is still below the level, at most near away | 0.05 |
recent | "Just broke out": a breakout within the last recent sessions and the price is still on the other side of the level | 5 |
| Returns | Content |
|---|---|
breakout | Panel: 1 on a breakout session with enough volume (bearish patterns: the breakdown session), 0 otherwise — use as a strategy's entry |
pattern, names | Panel of the pattern code present at each session (NaN when none) and an array of names by code |
stage, stages | Panel: 0 none, 1 near breakout, 2 just broke out; an array of stage names |
level, distance | Breakout level of the current pattern; close ÷ level − 1 (negative means still below the level) |
since, volRatio | Sessions since the breakout; breakout-session volume ÷ avg20 (just after the breakout) |
events | Every breakout / breakdown: { symbol, row, t, day, pattern, name, bullish, level, volRatio, start } — for event studies |
Codes in pattern follow the order cup (0), doubleBottom (1), ascTriangle (2), invHeadShoulders (3), flag (4), vcp (5), doubleTop (6), headShoulders (7) — i.e. names[k]. If a ticker has several patterns at once, pattern and stage take the pattern with the higher stage (just broke out before near breakout). ta.PATTERNS is an information table for each pattern by key: { name, bullish, level } (name, whether it is bullish, the name of the breakout level such as "miệng cốc" (cup rim), "đỉnh giữa" (middle peak)) — use it when studying events yourself.
| Pattern | Geometry (confirmed ZigZag peaks, troughs) | Breakout level |
|---|---|---|
cup | Cup 12–50% deep, the two rims differ by at most 8%, 25–250 sessions long; handle corrects at most 18%, in the upper half of the cup, within 40 sessions | Cup rim (right rim) |
doubleBottom | Two troughs differing by at most 5%, 15–150 sessions apart; the middle peak at least 10% above both troughs | Middle peak |
ascTriangle | Two peaks differing by at most 3%; the later trough at least 3% above the earlier one; 15–150 sessions | The higher of the two peaks |
invHeadShoulders | Head at least 3% below both shoulders; shoulders differ by at most 10%; 20–180 sessions | Neckline joining the two peaks (may slope) |
flag | Flagpole rising at least 20% within at most 25 sessions; the correction is no more than half the pole, within at most 20 sessions | Top of the flagpole |
vcp | Three progressively smaller corrections (the first at least 12%, the last at most 12%), peaks differ by at most 10%, 25–250 sessions, price above the price 200 sessions earlier | Peak of the last contraction |
doubleTop | Two peaks differing by at most 5%, 15–150 sessions apart; the middle trough at least 10% below both peaks | Middle trough (breakdown) |
headShoulders | Head at least 3% above both shoulders; shoulders differ by at most 10%; 20–180 sessions | Neckline joining the two troughs (breakdown) |
ta.zigzag(d, 0.08) returns the ZigZag peaks / troughs of each ticker: an array by row, each element { i, price, kind, at } (kind 1 is a peak, −1 a trough; i is the session of the peak / trough, at the session it was confirmed — always after i). Examples in strategies and screeners: buy on a pattern breakout, a screener with text columns; the full code of the Pattern group templates (Template list) is in the Mã (Code) tab when you open the template.
Panel operations
Arithmetic — returns a new Panel; NaN propagates through operations.
| Function | Meaning |
|---|---|
add(y) sub(y) mul(y) div(y) | Add, subtract, multiply, divide; divide by 0 → NaN |
pow(y) | Power |
min(y) max(y) | Smaller / larger element-wise (NaN on either side → NaN) |
neg() abs() sign() | Negate, absolute value, sign (−1 / 0 / 1) |
log() exp() sqrt() | Natural log (≤ 0 → NaN), exponential, square root (< 0 → NaN) |
round(chữSố = 0) clip(dưới, trên) | Round, clamp to a range |
map(fn) | Apply a custom function to each element |
Comparison and logic — results are 1 / 0 / NaN.
| Function | Meaning |
|---|---|
gt gte lt lte eq neq | >, ≥, <, ≤, =, ≠ |
between(dưới, trên) | Within the range, inclusive |
and(y) or(y) not() | Three-valued logic: 0 and NaN = 0, 1 or NaN = 1 |
where(điềuKiện, khác = NaN) | Keep the value when the condition is true, otherwise take khác (a number or Panel) |
isNaN() notNaN() | 1 if data is missing / present |
fillna(v) | Replace NaN with v |
ffill(giớiHạn?) | Forward-fill the most recent previous value, for at most n sessions |
Over time — computed per ticker, using only the past.
| Function | Meaning |
|---|---|
shift(n = 1) | The value n sessions earlier (n ≥ 0; a negative number raises a look-ahead error) |
diff(n = 1) | x − x n sessions earlier |
pct(n = 1) | x ÷ x n sessions earlier − 1 |
cumsum() cumprod() cummax() cummin() | Cumulative from the first value with data |
ewm(span) | Exponential average (like ta.ema) |
highest(n) lowest(n) | Highest / lowest over the last n sessions (including the current session) |
crossAbove(y) | 1 on the session it crosses above: previous session ≤ y, this session > y |
crossBelow(y) | 1 on the session it crosses below: previous session ≥ y, this session < y |
barsSince() | Sessions since the condition was last true (0 on that session itself; never true → NaN) |
hold(n) | Keep the true state for n more sessions after each true |
Rolling window — x.rolling(n).…: needs n consecutive non-NaN values.
| Function | Meaning |
|---|---|
.mean() .sum() | n-session mean, sum |
.std(mẫu = false) .var(mẫu = false) | Standard deviation, variance (divides by n by default; true divides by n − 1) |
.min() .max() | Minimum, maximum |
.count() | Number of values with data in n sessions (does not need all n) |
.rank() | Position of the current value within n sessions, 0 (lowest) → 1 (highest) |
.zscore() | (x − n-session mean) ÷ n-session standard deviation |
Cross-sectional — compares tickers within each session (skipping NaN tickers).
| Function | Meaning |
|---|---|
rank() | Percentile rank: 0 = lowest, 1 = highest; ties get the average rank |
zscore() demean() | Standardize by the mean and standard deviation across tickers; subtract the mean |
bucket(q) | Quantile bucket 1…q (q = 5: quintiles, 5 = highest) |
topN(n) bottomN(n) | 1 for the n largest / smallest tickers each session, 0 for the others |
sumAcross() meanAcross() countAcross() | Sum, mean, count of tickers with data — a single-row Panel |
mean() | A single number: the mean of the whole Panel (only for use in analyses) |
Getting values, slicing, resampling
| Function | Meaning |
|---|---|
last(t?) | A Row of the last session's (or session t's) value for each ticker: .get("FPT"), .values, .toObject(), .truthySymbols() (tickers whose value is true) |
at(ngày) | A Row at the latest session on or before the date (a day number, see dates.parse) |
values("FPT") · row(i) · get(i, t) | Array of one ticker's values (a copy) · array of row i · a single cell |
pick(["FPT", "HPG"]) · range(t ừNgày, đếnNgày) · sliceCols(từ, đến) | Select tickers · slice by date · slice by session index |
symbols days rows cols | Ticker list, session dates, number of rows, number of sessions |
resample("week" | "month" | "quarter" | "year") + .last() .first() .sum() .mean() .max() .min() | Aggregate by week (starting Monday), month, quarter, year; each period's date is its last session (an unfinished period: the latest session) |
Building a Panel: Panel.fromRows(tênHàng, ngày, mảngCácHàng), Panel.full(tênHàng, ngày, giáTrị) — example.
Statistics: stats.*
Takes number arrays (or a Float32Array from row(i), values(…)), ignoring NaN.
| Function | Meaning |
|---|---|
stats.mean(a) stats.median(a) | Mean, median |
stats.std(a) stats.variance(a) | Sample standard deviation, variance (divides by n − 1) |
stats.quantile(a, q) | Quantile q (0–1), linear interpolation |
stats.skew(a) stats.kurtosis(a) | Skewness; kurtosis (normal distribution = 3, not minus 3) |
stats.corr(a, b) stats.cov(a, b) | Correlation, covariance (only pairs where both have data) |
stats.linreg(x, y) | Regression y = intercept + slope × x → { slope, intercept, r2 } |
stats.tstat(a) | Mean ÷ standard error; an absolute value above 2 ≈ statistically significant |
stats.sharpe(lợiNhuậnPhiên, 250) | Annualized Sharpe = mean ÷ standard deviation × √250 (risk-free rate 0) |
stats.returns(chuỗiGiá) | Per-session returns (one element shorter) |
stats.drawdown(chuỗiGiá) | Decline from the peak at each point (≤ 0) |
stats.maxDrawdown(chuỗiGiá) | Maximum drawdown (a negative number). A series with NaN cells (a ticker listed after the start of the period) gives NaN — in that case take the minimum of stats.drawdown(…) |
stats.drawdowns(chuỗiGiá, d.days, 10) | The deepest drawdowns: { peakDay, troughDay, recoveryDay, depth, toTrough, toRecover } (recoveryDay is NaN if not yet recovered) |
stats.forward(chuỗiGiá, h) | The return over the next h sessions at each point — for event studies only, not as a signal |
stats.hist(a, 30, [dưới, trên]?) | { edges, counts } of the distribution |
stats.normCdf(x) stats.normInv(p) | Standard normal distribution function and its inverse |
Dates: dates.*
Dates in the SDK are the number of days since 01 Jan 1970 (d.days[t], peakDay…).
| Function | Meaning |
|---|---|
dates.parse("2020-01-15") | String → day number; accepts "2020-01-15", "2020", "15/01/2020" |
dates.format(ngày) | Day number → "15/01/2020" (for display) |
dates.iso(ngày) | Day number → "2020-01-15" |
dates.year(ngày) dates.month(ngày) dates.day(ngày) | Year; month 1–12; day 1–31 |
dates.weekday(ngày) | 0 = Sunday, 1 = Monday … 6 = Saturday |
dates.today() | Today (day number) |
Value formats
Used in the format of screener columns, metric, charts and tables.
| Format | Display |
|---|---|
"percent" | Multiplied by 100, 2 decimal places: 0.0523 → 5.23% |
"price" | 2 decimal places (price in VND thousand): 57.30 |
"compact" | Compact money: 12.50 tỷ (bn), 45.30 tr (mn) (from 100 up, decimals are dropped: 350 tr, 1,250 tỷ) |
"integer" | Integer with comma thousands separators |
"ratio" | 2 decimal places (coefficients, P/E, Sharpe) |
"number" | Number of decimal places chosen automatically by magnitude |
"date" | Day number → dd/mm/yyyy |
"text" | Text kept as is |
Numbers are displayed using the app's convention: comma thousands separators, dot decimal point.
Declaration summary
| Declaration | Fields | See |
|---|---|---|
strategy | name description universe period benchmark warmup params · signals | rank + select | weights · rebalance filter · portfolio risk execution costs rules · report | Strategy |
screen | name universe params columns filter sort limit lookback asOf includeToday | Screener |
research | name params run(ctx, p) — ctx: data.bars data.symbols metric chart table md log params | Analysis |
Quant AI Studio SDK의 모든 함수 참조표입니다. d의 데이터 필드는 데이터와 Panel, 전략 선언은 전략, 스크리너·분석과 출력은 스크리너와 분석에 있습니다. Studio에서는 Mã(코드) 탭의 Tài liệu SDK(SDK 문서) 버튼이 같은 내용의 요약본을 엽니다.
공통 규칙: x, y는 Panel입니다. Panel 연산에서 y는 숫자 또는 Panel(같은 모양이거나 d.bench.close 같은 한 행짜리 Panel)입니다. 결과를 낼 데이터가 부족한 칸은 NaN이 됩니다.
전역 함수
| 함수 | 의미 |
|---|---|
strategy({…}) | 백테스트 전략 선언 — 전략 |
screen({…}) | 스크리너 선언 — 스크리너 |
research(async (ctx) => …) · research({ name, params, run }) | 분석 선언 — 분석 |
universe(…) | 종목 바스켓 — 아래 |
param.* | 매개변수 — 아래 |
ta.*, stats.*, dates.* | 지표, 통계, 날짜 — 아래 |
log(…giáTrị) | Nhật ký chạy(실행 로그)에 출 력(Panel은 요약 출력: 종목 수 × 세션 수, 마지막 세션 값). console.log도 같음 |
byYearMonth(panelTháng, hàng = 0) | chart.heatmap용 연 × 월 표 { xLabels: ["T1"…"T12"], yLabels: [năm], values }. 세션 단위 Panel이면 월말 값을 사용 |
monthOfYearMean(panelTháng, hàng = 0) | 연중 월별 통계: [{ month, mean, count, positive }](positive: 플러스였던 연도의 비율) |
Panel | Panel 만들기 — Panel 직접 만들기 |
매개변수: param.*
| 함수 | 매개변수 막대에서 | p.tên 값 |
|---|---|---|
param.int(14, { min, max, step, label }) | 정수 슬라이더(간격 1) | 정수 |
param.num(1.5, { min, max, step, label }) | 실수 슬라이더(값이 10 이상이면 기본 간격 1, 그 외 0.1) | 숫자 |
param.pct(0.07, { min, max, step, label }) | % 표시 슬라이더, 간격 0.5% | 비율(0.07 = 7%) |
param.bool(true, { label }) | Bật / Tắt(켜기 / 끄기) 스위치 | true / false |
param.choice("Momentum 6-1", ["Momentum 6-1", "Biến động thấp"], { label }) | 선택 상자 | 선택된 요소(문자열 또는 숫자) |
param.symbol("FPT", { label: "Mã" }) | 종목 코드 입력 칸(Enter를 누르거나 칸을 벗어나면 실행; Esc 취소) | 대문자 코드: 주식, 지수, ETF, 해외 지수(^GSPC) |
label은 매개변수 막대에 표시되는 글자입니다 — 짧은 베트남어로 쓰세요.min/max가 없으면:pct막대는 0 → max(50%, 기본값의 3배) 범위,int,num은 기본값 주변 범위입니다.[min, max]밖의 값은 범위 안으로 잘립니다.int는 반올림되고, 목록에 없는choice는 기본값으로, 형식이 잘못된 종목 코드도 기본값으로 돌아갑니다.- 단순 값으로 간단히 선언해도 됩니다:
params: { len: 14, ratio: 1.5, useStop: true }(정수 →int, 실수 →num, 참 / 거짓 →bool). - 화면에서 매개변수를 바꾸면 새 버전을 만들지 않고 바로 다시 실행됩니다. Mặc định(기본값) 버튼은 코드의 값으로 되돌립니다. 매개변수 최적화는
min–max범위를 탐색합니다(최적화와 견고성 검증).
종목 바스켓: universe(…)
| 작성법 | 포함 범위 |
|---|---|
universe("ALL") | HOSE, HNX, UPCoM |