Mẫu xu hướng
- 🇻🇳 Tiếng Việt
- 🇬🇧 English
- 🇰🇷 한국어
- 🇨🇳 中文
Chỉ báo theo xu hướng: đường trung bình, dải, Supertrend, Ichimoku, ADX, SAR, hồi quy, xu hướng nhiều khung. Sao chép, dán vào trình soạn, Thêm vào biểu đồ, rồi chỉnh tham số.
Dải EMA Fibonacci
Năm EMA 8 – 13 – 21 – 34 – 55. Dải xếp đúng thứ tự (ngắn trên dài) và toả rộng là xu hướng tăng khoẻ; xoắn vào nhau là đi ngang.
indicator({
name: "Dải EMA Fibonacci",
pane: "price",
plot: (d) => {
const e = [8, 13, 21, 34, 55].map((n) => ta.ema(d.close, n));
const tang = e[0].gt(e[1]).and(e[1].gt(e[2])).and(e[2].gt(e[3])).and(e[3].gt(e[4]));
const giam = e[0].lt(e[1]).and(e[1].lt(e[2])).and(e[2].lt(e[3])).and(e[3].lt(e[4]));
return {
"EMA 8": line(e[0], { color: "palette.0", width: 1 }),
"EMA 13": line(e[1], { color: "palette.1", width: 1 }),
"EMA 21": line(e[2], { color: "palette.2", width: 1 }),
"EMA 34": line(e[3], { color: "palette.3", width: 1 }),
"EMA 55": line(e[4], { color: "palette.4", width: 2 }),
"Xếp tăng": bgcolor(tang, { color: "up", opacity: 0.06 }),
"Xếp giảm": bgcolor(giam, { color: "down", opacity: 0.06 }),
};
},
});
Giao cắt vàng / giao cắt tử thần
MA 50 cắt lên MA 200 (giao cắt vàng) và cắt xuống (giao cắt tử thần), có cảnh báo.
indicator({
name: "Giao cắt vàng / tử thần",
pane: "price",
params: {
fast: param.int(50, { min: 10, max: 100, label: "MA nhanh" }),
slow: param.int(200, { min: 100, max: 300, label: "MA chậm" }),
},
plot: (d, p) => {
const f = ta.sma(d.close, p.fast);
const s = ta.sma(d.close, p.slow);
return {
[`MA ${p.fast}`]: line(f, { color: "ref", width: 2 }),
[`MA ${p.slow}`]: line(s, { color: "ceil", width: 2 }),
"Giao cắt vàng": shape(f.crossAbove(s), { at: "below", shape: "label", text: "Vàng", color: "up" }),
"Giao cắt tử thần": shape(f.crossBelow(s), { at: "above", shape: "label", text: "Tử thần", color: "down" }),
};
},
alerts: (d, p) => ({
"Giao cắt vàng": ta.sma(d.close, p.fast).crossAbove(ta.sma(d.close, p.slow)),
"Giao cắt tử thần": ta.sma(d.close, p.fast).crossBelow(ta.sma(d.close, p.slow)),
}),
});
Supertrend hai màu
Mẫu Supertrend hai màu của thư viện: đường xanh khi xu hướng tăng, đỏ khi giảm, mũi tên khi đổi chiều.
indicator({
name: "Supertrend hai màu",
pane: "price",
params: {
n: param.int(10, { min: 3, max: 50, label: "Chu kỳ ATR" }),
mult: param.num(3, { min: 1, max: 6, step: 0.5, label: "Hệ số ATR" }),
},
plot: (d, p) => {
const st = ta.supertrend(d, p.n, p.mult);
return {
"Xu hướng tăng": line(st.line.where(st.dir.gt(0)), { color: "up", width: 2 }),
"Xu hướng giảm": line(st.line.where(st.dir.lt(0)), { color: "down", width: 2 }),
"Đảo lên": shape(st.dir.crossAbove(0), { at: "below", shape: "arrowUp", color: "up" }),
"Đảo xuống": shape(st.dir.crossBelow(0), { at: "above", shape: "arrowDown", color: "down" }),
};
},
alerts: (d, p) => {
const st = ta.supertrend(d, p.n, p.mult);
return { "Supertrend đảo lên": st.dir.crossAbove(0), "Supertrend đảo xuống": st.dir.crossBelow(0) };
},
});
st.line.where(st.dir.gt(0)) giữ đường ở nến xu hướng tăng, để trống ở nến khác — hai đầu ra ghép lại thành một đường hai màu.
Mây Ichimoku có dời
Tenkan, Kijun, mây Senkou A / B vẽ dời 26 nến về phía trước như cách đọc truyền thống (offset chỉ dời hình; tín hiệu dùng giá trị chưa dời nên không nhìn trước), và đường Chikou (giá dời lùi).
indicator({
name: "Ichimoku có dời",
pane: "price",
params: { kijunN: param.int(26, { min: 10, max: 60, label: "Kijun / độ dời" }) },
plot: (d, p) => {
const ich = ta.ichimoku(d, 9, p.kijunN, 52);
return {
Tenkan: line(ich.tenkan, { color: "accent" }),
Kijun: line(ich.kijun, { color: "down" }),
"Senkou A": line(ich.spanA, { color: "up", offset: p.kijunN, opacity: 0.6 }),
"Senkou B": line(ich.spanB, { color: "down", offset: p.kijunN, opacity: 0.6 }),
"Mây": fill("Senkou A", "Senkou B", { color: "up", below: "down", opacity: 0.1 }),
Chikou: line(d.close, { color: "textMuted", offset: -p.kijunN, hidden: true }),
"Giá trên mây": shape(d.close.crossAbove(ich.spanA.shift(p.kijunN).max(ich.spanB.shift(p.kijunN))), { at: "below", shape: "triangleUp", color: "up" }),
};
},
});
"Giá trên mây" so giá với mây đang hiện ở nến này — tức giá trị mây tính từ 26 nến trước (shift(p.kijunN)).
Sức mạnh xu hướng ADX / DMI
ADX trên 25 là có xu hướng; +DI trên −DI là xu hướng tăng. Tô nền theo trạng thái.
indicator({
name: "ADX / DMI có trạng thái",
scale: { levels: [20, 25, 40] },
params: {
n: param.int(14, { min: 5, max: 50, label: "Chu kỳ" }),
nguong: param.int(25, { min: 10, max: 50, label: "Ngưỡng có xu hướng" }),
},
plot: (d, p) => {
const a = ta.adx(d, p.n);
const coXuHuong = a.adx.gt(p.nguong);
return {
ADX: line(a.adx, { color: "text", width: 2 }),
"+DI": line(a.plusDI, { color: "up" }),
"-DI": line(a.minusDI, { color: "down" }),
"Tăng có xu hướng": bgcolor(coXuHuong.and(a.plusDI.gt(a.minusDI)), { color: "up", opacity: 0.08 }),
"Giảm có xu hướng": bgcolor(coXuHuong.and(a.minusDI.gt(a.plusDI)), { color: "down", opacity: 0.08 }),
};
},
alerts: (d, p) => ({ "ADX vượt ngưỡng": ta.adx(d, p.n).adx.crossAbove(p.nguong) }),
});
Parabolic SAR và điểm đảo chiều
indicator({
name: "Parabolic SAR",
pane: "price",
params: {
step: param.num(0.02, { min: 0.005, max: 0.1, step: 0.005, label: "Bước" }),
max: param.num(0.2, { min: 0.1, max: 0.5, step: 0.05, label: "Tối đa" }),
},
plot: (d, p) => {
const sar = ta.psar(d, p.step, p.max);
const duoiGia = sar.lt(d.close);
return {
SAR: line(sar, { points: "circles", colors: [{ when: duoiGia, color: "up" }], color: "down" }),
"Đảo lên": shape(duoiGia.and(duoiGia.shift(1).fillna(1).not()), { at: "below", shape: "arrowUp", color: "up" }),
"Đảo xuống": shape(duoiGia.not().and(duoiGia.shift(1).fillna(0)), { at: "above", shape: "arrowDown", color: "down" }),
};
},
});
Kênh hồi quy tuyến tính
Đường hồi quy 100 nến và kênh ± 2 độ lệch chuẩn (chỉ báo linreg-channel của thư viện), kèm độ dốc để biết xu hướng mạnh hay yếu.
indicator({
name: "Kênh hồi quy",
pane: "price",
params: {
n: param.int(100, { min: 20, max: 300, label: "Số nến" }),
dev: param.num(2, { min: 1, max: 4, step: 0.5, label: "Độ lệch chuẩn" }),
},
plot: (d, p) => {
const k = ta.run("linreg-channel", { n: p.n, dev: p.dev });
const doc = ta.slope(d.close, p.n).div(d.close).mul(100);
return {
"Kênh": band(k.upper, k.lower, { color: "accent", opacity: 0.06 }),
"Hồi quy": line(k.mid, { color: "accent", dash: "dash" }),
"Độ dốc %/nến": line(doc, { pane: "Độ dốc", color: "ai", format: "number" }),
"0": hline(0, { pane: "Độ dốc" }),
};
},
});
Aroon
Aroon Up / Down đo số nến kể từ đỉnh / đáy n nến. Up trên 70 và Down dưới 30 là xu hướng tăng rõ.
indicator({
name: "Aroon",
scale: { range: [0, 100], levels: [30, 70] },
params: { n: param.int(25, { min: 5, max: 100, label: "Chu kỳ" }) },
plot: (d, p) => {
const a = ta.run("aroon", { n: p.n });
return {
"Aroon Up": line(a.up, { color: "up" }),
"Aroon Down": line(a.down, { color: "down" }),
"Up cắt lên Down": shape(a.up.crossAbove(a.down), { at: "bottom", shape: "triangleUp", color: "up" }),
};
},
});
Kênh Donchian và bứt phá
Mẫu Kênh Donchian và bứt phá của thư viện: kênh đỉnh / đáy n nến trước (không tính nến hiện tại) và cờ khi đóng cửa vượt đỉnh kênh.
indicator({
name: "Kênh Donchian và bứt phá",
pane: "price",
params: { n: param.int(20, { min: 5, max: 200, label: "Số nến" }) },
plot: (d, p) => {
const hi = d.high.highest(p.n).shift(1);
const lo = d.low.lowest(p.n).shift(1);
return {
Kênh: band(hi, lo, { color: "ref", opacity: 0.08 }),
"Đỉnh kênh": line(hi, { color: "up", dash: "dash" }),
"Đáy kênh": line(lo, { color: "down", dash: "dash" }),
"Bứt phá": shape(d.close.crossAbove(hi), { at: "below", shape: "flag", color: "up" }),
};
},
alerts: (d, p) => ({ "Giá vượt đỉnh kênh": d.close.crossAbove(d.high.highest(p.n).shift(1)) }),
});
Xu hướng ba khung: ngày, tuần, tháng
Một ngăn nhỏ ba hàng chấm: xanh nếu giá trên EMA 20 của khung đó, đỏ nếu dưới. Đọc nhanh "các khung có đồng thuận không".
indicator({
name: "Xu hướng ba khung",
scale: { range: [0, 4] },
plot: (d) => {
const tren = (b) => b.close.gt(ta.ema(b.close, 20));
const hang = (dk, muc) => d.const(muc).where(dk.notNaN());
const ngay = tren(d);
const tuan = tren(d.tf("1W"));
const thang = tren(d.tf("1M"));
return {
"Ngày": shape(ngay.notNaN(), { at: "value", value: hang(ngay, 3), shape: "circle", size: "s", colors: [{ when: ngay, color: "up" }], color: "down" }),
"Tuần": shape(tuan.notNaN(), { at: "value", value: hang(tuan, 2), shape: "circle", size: "s", colors: [{ when: tuan, color: "up" }], color: "down" }),
"Tháng": shape(thang.notNaN(), { at: "value", value: hang(thang, 1), shape: "circle", size: "s", colors: [{ when: thang, color: "up" }], color: "down" }),
};
},
alerts: (d) => {
const tren = (b) => b.close.gt(ta.ema(b.close, 20));
return { "Cả ba khung trên EMA 20": tren(d).and(tren(d.tf("1W"))).and(tren(d.tf("1M"))) };
},
});
tren là một hàm của bạn nhận dữ liệu (ngày, tuần hay tháng) và trả điều kiện — viết một lần, dùng ba lần.
Trend-following indicators: moving averages, ribbons, Supertrend, Ichimoku, ADX, SAR, regression, multi-timeframe trend. Copy, paste into the editor, click Thêm vào biểu đồ (Add to chart), then adjust the parameters.
Fibonacci EMA ribbon
Five EMAs: 8 – 13 – 21 – 34 – 55. A ribbon in the right order (short above long) and fanning out is a strong uptrend; intertwined lines mean sideways movement.
indicator({
name: "Dải EMA Fibonacci",
pane: "price",
plot: (d) => {
const e = [8, 13, 21, 34, 55].map((n) => ta.ema(d.close, n));
const tang = e[0].gt(e[1]).and(e[1].gt(e[2])).and(e[2].gt(e[3])).and(e[3].gt(e[4]));
const giam = e[0].lt(e[1]).and(e[1].lt(e[2])).and(e[2].lt(e[3])).and(e[3].lt(e[4]));
return {
"EMA 8": line(e[0], { color: "palette.0", width: 1 }),
"EMA 13": line(e[1], { color: "palette.1", width: 1 }),
"EMA 21": line(e[2], { color: "palette.2", width: 1 }),
"EMA 34": line(e[3], { color: "palette.3", width: 1 }),
"EMA 55": line(e[4], { color: "palette.4", width: 2 }),
"Xếp tăng": bgcolor(tang, { color: "up", opacity: 0.06 }),
"Xếp giảm": bgcolor(giam, { color: "down", opacity: 0.06 }),
};
},
});
Golden cross / death cross
MA 50 crossing above MA 200 (golden cross) and below it (death cross), with alerts.
indicator({
name: "Giao cắt vàng / tử thần",
pane: "price",
params: {
fast: param.int(50, { min: 10, max: 100, label: "MA nhanh" }),
slow: param.int(200, { min: 100, max: 300, label: "MA chậm" }),
},
plot: (d, p) => {
const f = ta.sma(d.close, p.fast);
const s = ta.sma(d.close, p.slow);
return {
[`MA ${p.fast}`]: line(f, { color: "ref", width: 2 }),
[`MA ${p.slow}`]: line(s, { color: "ceil", width: 2 }),
"Giao cắt vàng": shape(f.crossAbove(s), { at: "below", shape: "label", text: "Vàng", color: "up" }),
"Giao cắt tử thần": shape(f.crossBelow(s), { at: "above", shape: "label", text: "Tử thần", color: "down" }),
};
},
alerts: (d, p) => ({
"Giao cắt vàng": ta.sma(d.close, p.fast).crossAbove(ta.sma(d.close, p.slow)),
"Giao cắt tử thần": ta.sma(d.close, p.fast).crossBelow(ta.sma(d.close, p.slow)),
}),
});
Two-color Supertrend
The library template Supertrend hai màu (Two-color Supertrend): a green line in an uptrend, red in a downtrend, and arrows when the direction flips.
indicator({
name: "Supertrend hai màu",
pane: "price",
params: {
n: param.int(10, { min: 3, max: 50, label: "Chu kỳ ATR" }),
mult: param.num(3, { min: 1, max: 6, step: 0.5, label: "Hệ số ATR" }),
},
plot: (d, p) => {
const st = ta.supertrend(d, p.n, p.mult);
return {
"Xu hướng tăng": line(st.line.where(st.dir.gt(0)), { color: "up", width: 2 }),
"Xu hướng giảm": line(st.line.where(st.dir.lt(0)), { color: "down", width: 2 }),
"Đảo lên": shape(st.dir.crossAbove(0), { at: "below", shape: "arrowUp", color: "up" }),
"Đảo xuống": shape(st.dir.crossBelow(0), { at: "above", shape: "arrowDown", color: "down" }),
};
},
alerts: (d, p) => {
const st = ta.supertrend(d, p.n, p.mult);
return { "Supertrend đảo lên": st.dir.crossAbove(0), "Supertrend đảo xuống": st.dir.crossBelow(0) };
},
});
st.line.where(st.dir.gt(0)) keeps the line on uptrend bars and leaves it blank on the others — the two outputs combine into one two-color line.
Displaced Ichimoku cloud
Tenkan, Kijun, and the Senkou A / B cloud drawn displaced 26 bars forward as in the traditional reading (offset only shifts the drawing; signals use the undisplaced values, so there is no look-ahead), plus the Chikou line (price shifted backward).
indicator({
name: "Ichimoku có dời",
pane: "price",
params: { kijunN: param.int(26, { min: 10, max: 60, label: "Kijun / độ dời" }) },
plot: (d, p) => {
const ich = ta.ichimoku(d, 9, p.kijunN, 52);
return {
Tenkan: line(ich.tenkan, { color: "accent" }),
Kijun: line(ich.kijun, { color: "down" }),
"Senkou A": line(ich.spanA, { color: "up", offset: p.kijunN, opacity: 0.6 }),
"Senkou B": line(ich.spanB, { color: "down", offset: p.kijunN, opacity: 0.6 }),
"Mây": fill("Senkou A", "Senkou B", { color: "up", below: "down", opacity: 0.1 }),
Chikou: line(d.close, { color: "textMuted", offset: -p.kijunN, hidden: true }),
"Giá trên mây": shape(d.close.crossAbove(ich.spanA.shift(p.kijunN).max(ich.spanB.shift(p.kijunN))), { at: "below", shape: "triangleUp", color: "up" }),
};
},
});
"Giá trên mây" (Price above cloud) compares price with the cloud shown on this bar — that is, the cloud values computed 26 bars earlier (shift(p.kijunN)).
ADX / DMI trend strength
ADX above 25 means there is a trend; +DI above −DI means an uptrend. The background is shaded by state.
indicator({
name: "ADX / DMI có trạng thái",
scale: { levels: [20, 25, 40] },
params: {
n: param.int(14, { min: 5, max: 50, label: "Chu kỳ" }),
nguong: param.int(25, { min: 10, max: 50, label: "Ngưỡng có xu hướng" }),
},
plot: (d, p) => {
const a = ta.adx(d, p.n);
const coXuHuong = a.adx.gt(p.nguong);
return {
ADX: line(a.adx, { color: "text", width: 2 }),
"+DI": line(a.plusDI, { color: "up" }),
"-DI": line(a.minusDI, { color: "down" }),
"Tăng có xu hướng": bgcolor(coXuHuong.and(a.plusDI.gt(a.minusDI)), { color: "up", opacity: 0.08 }),
"Giảm có xu hướng": bgcolor(coXuHuong.and(a.minusDI.gt(a.plusDI)), { color: "down", opacity: 0.08 }),
};
},
alerts: (d, p) => ({ "ADX vượt ngưỡng": ta.adx(d, p.n).adx.crossAbove(p.nguong) }),
});
Parabolic SAR and reversal points
indicator({
name: "Parabolic SAR",
pane: "price",
params: {
step: param.num(0.02, { min: 0.005, max: 0.1, step: 0.005, label: "Bước" }),
max: param.num(0.2, { min: 0.1, max: 0.5, step: 0.05, label: "Tối đa" }),
},
plot: (d, p) => {
const sar = ta.psar(d, p.step, p.max);
const duoiGia = sar.lt(d.close);
return {
SAR: line(sar, { points: "circles", colors: [{ when: duoiGia, color: "up" }], color: "down" }),
"Đảo lên": shape(duoiGia.and(duoiGia.shift(1).fillna(1).not()), { at: "below", shape: "arrowUp", color: "up" }),
"Đảo xuống": shape(duoiGia.not().and(duoiGia.shift(1).fillna(0)), { at: "above", shape: "arrowDown", color: "down" }),
};
},
});
Linear regression channel
A 100-bar regression line and a ± 2 standard deviation channel (the library's linreg-channel indicator), plus the slope to tell whether the trend is strong or weak.
indicator({
name: "Kênh hồi quy",
pane: "price",
params: {
n: param.int(100, { min: 20, max: 300, label: "Số nến" }),
dev: param.num(2, { min: 1, max: 4, step: 0.5, label: "Độ lệch chuẩn" }),
},
plot: (d, p) => {
const k = ta.run("linreg-channel", { n: p.n, dev: p.dev });
const doc = ta.slope(d.close, p.n).div(d.close).mul(100);
return {
"Kênh": band(k.upper, k.lower, { color: "accent", opacity: 0.06 }),
"Hồi quy": line(k.mid, { color: "accent", dash: "dash" }),
"Độ dốc %/nến": line(doc, { pane: "Độ dốc", color: "ai", format: "number" }),
"0": hline(0, { pane: "Độ dốc" }),
};
},
});
Aroon
Aroon Up / Down measure the number of bars since the n-bar high / low. Up above 70 and Down below 30 indicates a clear uptrend.
indicator({
name: "Aroon",
scale: { range: [0, 100], levels: [30, 70] },
params: { n: param.int(25, { min: 5, max: 100, label: "Chu kỳ" }) },
plot: (d, p) => {
const a = ta.run("aroon", { n: p.n });
return {
"Aroon Up": line(a.up, { color: "up" }),
"Aroon Down": line(a.down, { color: "down" }),
"Up cắt lên Down": shape(a.up.crossAbove(a.down), { at: "bottom", shape: "triangleUp", color: "up" }),
};
},
});
Donchian channel and breakout
The library template Kênh Donchian và bứt phá (Donchian channel and breakout): a channel of the high / low of the previous n bars (excluding the current bar) and a flag when the close breaks above the top of the channel.
indicator({
name: "Kênh Donchian và bứt phá",
pane: "price",
params: { n: param.int(20, { min: 5, max: 200, label: "Số nến" }) },
plot: (d, p) => {
const hi = d.high.highest(p.n).shift(1);
const lo = d.low.lowest(p.n).shift(1);
return {
Kênh: band(hi, lo, { color: "ref", opacity: 0.08 }),
"Đỉnh kênh": line(hi, { color: "up", dash: "dash" }),
"Đáy kênh": line(lo, { color: "down", dash: "dash" }),
"Bứt phá": shape(d.close.crossAbove(hi), { at: "below", shape: "flag", color: "up" }),
};
},
alerts: (d, p) => ({ "Giá vượt đỉnh kênh": d.close.crossAbove(d.high.highest(p.n).shift(1)) }),
});
Three-timeframe trend: daily, weekly, monthly
A small pane with three rows of dots: green if price is above that timeframe's EMA 20, red if below. A quick read of "do the timeframes agree".
indicator({
name: "Xu hướng ba khung",
scale: { range: [0, 4] },
plot: (d) => {
const tren = (b) => b.close.gt(ta.ema(b.close, 20));
const hang = (dk, muc) => d.const(muc).where(dk.notNaN());
const ngay = tren(d);
const tuan = tren(d.tf("1W"));
const thang = tren(d.tf("1M"));
return {
"Ngày": shape(ngay.notNaN(), { at: "value", value: hang(ngay, 3), shape: "circle", size: "s", colors: [{ when: ngay, color: "up" }], color: "down" }),
"Tuần": shape(tuan.notNaN(), { at: "value", value: hang(tuan, 2), shape: "circle", size: "s", colors: [{ when: tuan, color: "up" }], color: "down" }),
"Tháng": shape(thang.notNaN(), { at: "value", value: hang(thang, 1), shape: "circle", size: "s", colors: [{ when: thang, color: "up" }], color: "down" }),
};
},
alerts: (d) => {
const tren = (b) => b.close.gt(ta.ema(b.close, 20));
return { "Cả ba khung trên EMA 20": tren(d).and(tren(d.tf("1W"))).and(tren(d.tf("1M"))) };
},
});
tren is your own function that takes data (daily, weekly or monthly) and returns a condition — write it once, use it three times.
추세 지표: 이동평균, 리본, 슈퍼트렌드, 일목균형표, ADX, SAR, 회귀, 다중 주기 추세. 복사해서 편집기에 붙여 넣고 Thêm vào biểu đồ(차트에 추가)를 누른 뒤 파라미터를 조정하세요.
피보나치 EMA 리본
EMA 8 – 13 – 21 – 34 – 55 다섯 개입니다. 리본이 순서대로 정렬되고(짧은 것이 긴 것 위) 넓게 벌어지면 강한 상승 추세, 서로 꼬이면 횡보입니다.
indicator({
name: "Dải EMA Fibonacci",
pane: "price",
plot: (d) => {
const e = [8, 13, 21, 34, 55].map((n) => ta.ema(d.close, n));
const tang = e[0].gt(e[1]).and(e[1].gt(e[2])).and(e[2].gt(e[3])).and(e[3].gt(e[4]));
const giam = e[0].lt(e[1]).and(e[1].lt(e[2])).and(e[2].lt(e[3])).and(e[3].lt(e[4]));
return {
"EMA 8": line(e[0], { color: "palette.0", width: 1 }),
"EMA 13": line(e[1], { color: "palette.1", width: 1 }),
"EMA 21": line(e[2], { color: "palette.2", width: 1 }),
"EMA 34": line(e[3], { color: "palette.3", width: 1 }),
"EMA 55": line(e[4], { color: "palette.4", width: 2 }),
"Xếp tăng": bgcolor(tang, { color: "up", opacity: 0.06 }),
"Xếp giảm": bgcolor(giam, { color: "down", opacity: 0.06 }),
};
},
});
골든 크로스 / 데드 크로스
MA 50이 MA 200을 상향 돌파(골든 크로스)하거나 하향 돌파(데드 크로스)할 때 표시하며, 알림이 있습니다.
indicator({
name: "Giao cắt vàng / tử thần",
pane: "price",
params: {
fast: param.int(50, { min: 10, max: 100, label: "MA nhanh" }),
slow: param.int(200, { min: 100, max: 300, label: "MA chậm" }),
},
plot: (d, p) => {
const f = ta.sma(d.close, p.fast);
const s = ta.sma(d.close, p.slow);
return {
[`MA ${p.fast}`]: line(f, { color: "ref", width: 2 }),
[`MA ${p.slow}`]: line(s, { color: "ceil", width: 2 }),
"Giao cắt vàng": shape(f.crossAbove(s), { at: "below", shape: "label", text: "Vàng", color: "up" }),
"Giao cắt tử thần": shape(f.crossBelow(s), { at: "above", shape: "label", text: "Tử thần", color: "down" }),
};
},
alerts: (d, p) => ({
"Giao cắt vàng": ta.sma(d.close, p.fast).crossAbove(ta.sma(d.close, p.slow)),
"Giao cắt tử thần": ta.sma(d.close, p.fast).crossBelow(ta.sma(d.close, p.slow)),
}),
});
두 색 슈퍼트렌드
라이브러리의 Supertrend hai màu(두 색 슈퍼트렌드) 템플릿: 상승 추세에서는 초록 선, 하락 추세에서는 빨간 선, 방향이 바뀌면 화살표를 표시합니다.
indicator({
name: "Supertrend hai màu",
pane: "price",
params: {
n: param.int(10, { min: 3, max: 50, label: "Chu kỳ ATR" }),
mult: param.num(3, { min: 1, max: 6, step: 0.5, label: "Hệ số ATR" }),
},
plot: (d, p) => {
const st = ta.supertrend(d, p.n, p.mult);
return {
"Xu hướng tăng": line(st.line.where(st.dir.gt(0)), { color: "up", width: 2 }),
"Xu hướng giảm": line(st.line.where(st.dir.lt(0)), { color: "down", width: 2 }),
"Đảo lên": shape(st.dir.crossAbove(0), { at: "below", shape: "arrowUp", color: "up" }),
"Đảo xuống": shape(st.dir.crossBelow(0), { at: "above", shape: "arrowDown", color: "down" }),
};
},
alerts: (d, p) => {
const st = ta.supertrend(d, p.n, p.mult);
return { "Supertrend đảo lên": st.dir.crossAbove(0), "Supertrend đảo xuống": st.dir.crossBelow(0) };
},
});
st.line.where(st.dir.gt(0))은 상승 추세 봉에서만 선을 남기고 다른 봉은 비워 둡니다. 두 출력이 합쳐져 두 색의 선 하나가 됩니다.
이동을 적용한 일목균형표 구름
전환선(Tenkan), 기준선(Kijun), 선행스팬 A / B 구름을 전통적인 읽기 방식대로 26개 봉 앞으로 이동해 그리고(offset은 그림만 이동합니다. 신호는 이동하지 않은 값을 쓰므로 미래를 보지 않습니다), 후행스팬(Chikou, 뒤로 이동한 가격)도 그립니다.
indicator({
name: "Ichimoku có dời",
pane: "price",
params: { kijunN: param.int(26, { min: 10, max: 60, label: "Kijun / độ dời" }) },
plot: (d, p) => {
const ich = ta.ichimoku(d, 9, p.kijunN, 52);
return {
Tenkan: line(ich.tenkan, { color: "accent" }),
Kijun: line(ich.kijun, { color: "down" }),
"Senkou A": line(ich.spanA, { color: "up", offset: p.kijunN, opacity: 0.6 }),
"Senkou B": line(ich.spanB, { color: "down", offset: p.kijunN, opacity: 0.6 }),
"Mây": fill("Senkou A", "Senkou B", { color: "up", below: "down", opacity: 0.1 }),
Chikou: line(d.close, { color: "textMuted", offset: -p.kijunN, hidden: true }),
"Giá trên mây": shape(d.close.crossAbove(ich.spanA.shift(p.kijunN).max(ich.spanB.shift(p.kijunN))), { at: "below", shape: "triangleUp", color: "up" }),
};
},
});
"Giá trên mây"(구름 위의 가격)는 가격을 이 봉에 표시되는 구름, 즉 26개 봉 전에 계산된 구름 값(shift(p.kijunN))과 비교합니다.
ADX / DMI 추세 강도
ADX가 25를 넘으면 추세가 있고, +DI가 −DI보다 위면 상승 추세입니다. 상태에 따라 배경을 칠합니다.
indicator({
name: "ADX / DMI có trạng thái",
scale: { levels: [20, 25, 40] },
params: {
n: param.int(14, { min: 5, max: 50, label: "Chu kỳ" }),
nguong: param.int(25, { min: 10, max: 50, label: "Ngưỡng có xu hướng" }),
},
plot: (d, p) => {
const a = ta.adx(d, p.n);
const coXuHuong = a.adx.gt(p.nguong);
return {
ADX: line(a.adx, { color: "text", width: 2 }),
"+DI": line(a.plusDI, { color: "up" }),
"-DI": line(a.minusDI, { color: "down" }),
"Tăng có xu hướng": bgcolor(coXuHuong.and(a.plusDI.gt(a.minusDI)), { color: "up", opacity: 0.08 }),
"Giảm có xu hướng": bgcolor(coXuHuong.and(a.minusDI.gt(a.plusDI)), { color: "down", opacity: 0.08 }),
};
},
alerts: (d, p) => ({ "ADX vượt ngưỡng": ta.adx(d, p.n).adx.crossAbove(p.nguong) }),
});
파라볼릭 SAR과 반전 지점
indicator({
name: "Parabolic SAR",
pane: "price",
params: {
step: param.num(0.02, { min: 0.005, max: 0.1, step: 0.005, label: "Bước" }),
max: param.num(0.2, { min: 0.1, max: 0.5, step: 0.05, label: "Tối đa" }),
},
plot: (d, p) => {
const sar = ta.psar(d, p.step, p.max);
const duoiGia = sar.lt(d.close);
return {
SAR: line(sar, { points: "circles", colors: [{ when: duoiGia, color: "up" }], color: "down" }),
"Đảo lên": shape(duoiGia.and(duoiGia.shift(1).fillna(1).not()), { at: "below", shape: "arrowUp", color: "up" }),
"Đảo xuống": shape(duoiGia.not().and(duoiGia.shift(1).fillna(0)), { at: "above", shape: "arrowDown", color: "down" }),
};
},
});
선형 회귀 채널
100개 봉 회귀선과 ± 2 표준편차 채널(라이브러리의 linreg-channel 지표)에 기울기를 더해 추세의 강약을 알 수 있습니다.
indicator({
name: "Kênh hồi quy",
pane: "price",
params: {
n: param.int(100, { min: 20, max: 300, label: "Số nến" }),
dev: param.num(2, { min: 1, max: 4, step: 0.5, label: "Độ lệch chuẩn" }),
},
plot: (d, p) => {
const k = ta.run("linreg-channel", { n: p.n, dev: p.dev });
const doc = ta.slope(d.close, p.n).div(d.close).mul(100);
return {
"Kênh": band(k.upper, k.lower, { color: "accent", opacity: 0.06 }),
"Hồi quy": line(k.mid, { color: "accent", dash: "dash" }),
"Độ dốc %/nến": line(doc, { pane: "Độ dốc", color: "ai", format: "number" }),
"0": hline(0, { pane: "Độ dốc" }),
};
},
});
아룬(Aroon)
Aroon Up / Down은 n개 봉 고점 / 저점 이후 지난 봉 수를 측정합니다. Up이 70 이상이고 Down이 30 미만이면 뚜렷한 상승 추세입니다.
indicator({
name: "Aroon",
scale: { range: [0, 100], levels: [30, 70] },
params: { n: param.int(25, { min: 5, max: 100, label: "Chu kỳ" }) },
plot: (d, p) => {
const a = ta.run("aroon", { n: p.n });
return {
"Aroon Up": line(a.up, { color: "up" }),
"Aroon Down": line(a.down, { color: "down" }),
"Up cắt lên Down": shape(a.up.crossAbove(a.down), { at: "bottom", shape: "triangleUp", color: "up" }),
};
},
});
돈치안 채널과 돌파
라이브러리의 Kênh Donchian và bứt phá(돈치안 채널과 돌파) 템플릿: 이전 n개 봉(현재 봉 제외)의 고점 / 저점 채널과, 종가가 채널 상단을 넘을 때의 플래그입니다.
indicator({
name: "Kênh Donchian và bứt phá",
pane: "price",
params: { n: param.int(20, { min: 5, max: 200, label: "Số nến" }) },
plot: (d, p) => {
const hi = d.high.highest(p.n).shift(1);
const lo = d.low.lowest(p.n).shift(1);
return {
Kênh: band(hi, lo, { color: "ref", opacity: 0.08 }),
"Đỉnh kênh": line(hi, { color: "up", dash: "dash" }),
"Đáy kênh": line(lo, { color: "down", dash: "dash" }),
"Bứt phá": shape(d.close.crossAbove(hi), { at: "below", shape: "flag", color: "up" }),
};
},
alerts: (d, p) => ({ "Giá vượt đỉnh kênh": d.close.crossAbove(d.high.highest(p.n).shift(1)) }),
});
세 주기 추세: 일, 주, 월
점 세 줄로 된 작은 패널: 가격이 해당 주기의 EMA 20 위면 초록, 아래면 빨강입니다. "주기들이 서로 일치하는가"를 빠르게 읽을 수 있습니다.
indicator({
name: "Xu hướng ba khung",
scale: { range: [0, 4] },
plot: (d) => {
const tren = (b) => b.close.gt(ta.ema(b.close, 20));
const hang = (dk, muc) => d.const(muc).where(dk.notNaN());
const ngay = tren(d);
const tuan = tren(d.tf("1W"));
const thang = tren(d.tf("1M"));
return {
"Ngày": shape(ngay.notNaN(), { at: "value", value: hang(ngay, 3), shape: "circle", size: "s", colors: [{ when: ngay, color: "up" }], color: "down" }),
"Tuần": shape(tuan.notNaN(), { at: "value", value: hang(tuan, 2), shape: "circle", size: "s", colors: [{ when: tuan, color: "up" }], color: "down" }),
"Tháng": shape(thang.notNaN(), { at: "value", value: hang(thang, 1), shape: "circle", size: "s", colors: [{ when: thang, color: "up" }], color: "down" }),
};
},
alerts: (d) => {
const tren = (b) => b.close.gt(ta.ema(b.close, 20));
return { "Cả ba khung trên EMA 20": tren(d).and(tren(d.tf("1W"))).and(tren(d.tf("1M"))) };
},
});
tren은 데이터(일, 주 또는 월)를 받아 조건을 반환하는 여러분의 함수입니다. 한 번 작성해 세 번 사용합니다.
趋势类指标:移动平均线、均线带、Supertrend、Ichimoku、ADX、SAR、回归、多周期趋势。复制,粘贴到编辑器,Thêm vào biểu đồ(添加到图表),然后调整参数。
斐波那契 EMA 带
五条 EMA:8 – 13 – 21 – 34 – 55。均线带排列有序(短在上、长在下)且向外发散,是强劲的上升趋势;相互缠绕则是横盘。
indicator({
name: "Dải EMA Fibonacci",
pane: "price",
plot: (d) => {
const e = [8, 13, 21, 34, 55].map((n) => ta.ema(d.close, n));
const tang = e[0].gt(e[1]).and(e[1].gt(e[2])).and(e[2].gt(e[3])).and(e[3].gt(e[4]));
const giam = e[0].lt(e[1]).and(e[1].lt(e[2])).and(e[2].lt(e[3])).and(e[3].lt(e[4]));
return {
"EMA 8": line(e[0], { color: "palette.0", width: 1 }),
"EMA 13": line(e[1], { color: "palette.1", width: 1 }),
"EMA 21": line(e[2], { color: "palette.2", width: 1 }),
"EMA 34": line(e[3], { color: "palette.3", width: 1 }),
"EMA 55": line(e[4], { color: "palette.4", width: 2 }),
"Xếp tăng": bgcolor(tang, { color: "up", opacity: 0.06 }),
"Xếp giảm": bgcolor(giam, { color: "down", opacity: 0.06 }),
};
},
});
黄金交叉 / 死亡交叉
MA 50 上穿 MA 200(黄金交叉)与下穿(死亡交叉),带提醒。
indicator({
name: "Giao cắt vàng / tử thần",
pane: "price",
params: {
fast: param.int(50, { min: 10, max: 100, label: "MA nhanh" }),
slow: param.int(200, { min: 100, max: 300, label: "MA chậm" }),
},
plot: (d, p) => {
const f = ta.sma(d.close, p.fast);
const s = ta.sma(d.close, p.slow);
return {
[`MA ${p.fast}`]: line(f, { color: "ref", width: 2 }),
[`MA ${p.slow}`]: line(s, { color: "ceil", width: 2 }),
"Giao cắt vàng": shape(f.crossAbove(s), { at: "below", shape: "label", text: "Vàng", color: "up" }),
"Giao cắt tử thần": shape(f.crossBelow(s), { at: "above", shape: "label", text: "Tử thần", color: "down" }),
};
},
alerts: (d, p) => ({
"Giao cắt vàng": ta.sma(d.close, p.fast).crossAbove(ta.sma(d.close, p.slow)),
"Giao cắt tử thần": ta.sma(d.close, p.fast).crossBelow(ta.sma(d.close, p.slow)),
}),
});
双色 Supertrend
库中的 Supertrend hai màu(双色 Supertrend)模板:上升趋势时为绿线,下降时为红线,转向时显示箭头。
indicator({
name: "Supertrend hai màu",
pane: "price",
params: {
n: param.int(10, { min: 3, max: 50, label: "Chu kỳ ATR" }),
mult: param.num(3, { min: 1, max: 6, step: 0.5, label: "Hệ số ATR" }),
},
plot: (d, p) => {
const st = ta.supertrend(d, p.n, p.mult);
return {
"Xu hướng tăng": line(st.line.where(st.dir.gt(0)), { color: "up", width: 2 }),
"Xu hướng giảm": line(st.line.where(st.dir.lt(0)), { color: "down", width: 2 }),
"Đảo lên": shape(st.dir.crossAbove(0), { at: "below", shape: "arrowUp", color: "up" }),
"Đảo xuống": shape(st.dir.crossBelow(0), { at: "above", shape: "arrowDown", color: "down" }),
};
},
alerts: (d, p) => {
const st = ta.supertrend(d, p.n, p.mult);
return { "Supertrend đảo lên": st.dir.crossAbove(0), "Supertrend đảo xuống": st.dir.crossBelow(0) };
},
});
st.line.where(st.dir.gt(0)) 在上升趋势的 K 线上保留线,其他 K 线留空——两个输出拼合成一条双色线。
带位移的 Ichimoku 云
转换线(Tenkan)、基准线(Kijun)、先行带 Senkou A / B 云层按传统读法向前位移 26 根 K 线绘制(offset 只移动图形;信号使用未位移的值,因此不会预知未来),以及迟行线 Chikou(价格向后位移)。
indicator({
name: "Ichimoku có dời",
pane: "price",
params: { kijunN: param.int(26, { min: 10, max: 60, label: "Kijun / độ dời" }) },
plot: (d, p) => {
const ich = ta.ichimoku(d, 9, p.kijunN, 52);
return {
Tenkan: line(ich.tenkan, { color: "accent" }),
Kijun: line(ich.kijun, { color: "down" }),
"Senkou A": line(ich.spanA, { color: "up", offset: p.kijunN, opacity: 0.6 }),
"Senkou B": line(ich.spanB, { color: "down", offset: p.kijunN, opacity: 0.6 }),
"Mây": fill("Senkou A", "Senkou B", { color: "up", below: "down", opacity: 0.1 }),
Chikou: line(d.close, { color: "textMuted", offset: -p.kijunN, hidden: true }),
"Giá trên mây": shape(d.close.crossAbove(ich.spanA.shift(p.kijunN).max(ich.spanB.shift(p.kijunN))), { at: "below", shape: "triangleUp", color: "up" }),
};
},
});
“Giá trên mây”(价格位于云层之上)是把价格与显示在这根 K 线上的云层比较——即 26 根 K 线之前计 算出的云层值(shift(p.kijunN))。
ADX / DMI 趋势强度
ADX 高于 25 表示存在趋势;+DI 高于 −DI 表示上升趋势。按状态为背景着色。
indicator({
name: "ADX / DMI có trạng thái",
scale: { levels: [20, 25, 40] },
params: {
n: param.int(14, { min: 5, max: 50, label: "Chu kỳ" }),
nguong: param.int(25, { min: 10, max: 50, label: "Ngưỡng có xu hướng" }),
},
plot: (d, p) => {
const a = ta.adx(d, p.n);
const coXuHuong = a.adx.gt(p.nguong);
return {
ADX: line(a.adx, { color: "text", width: 2 }),
"+DI": line(a.plusDI, { color: "up" }),
"-DI": line(a.minusDI, { color: "down" }),
"Tăng có xu hướng": bgcolor(coXuHuong.and(a.plusDI.gt(a.minusDI)), { color: "up", opacity: 0.08 }),
"Giảm có xu hướng": bgcolor(coXuHuong.and(a.minusDI.gt(a.plusDI)), { color: "down", opacity: 0.08 }),
};
},
alerts: (d, p) => ({ "ADX vượt ngưỡng": ta.adx(d, p.n).adx.crossAbove(p.nguong) }),
});
Parabolic SAR 与反转点
indicator({
name: "Parabolic SAR",
pane: "price",
params: {
step: param.num(0.02, { min: 0.005, max: 0.1, step: 0.005, label: "Bước" }),
max: param.num(0.2, { min: 0.1, max: 0.5, step: 0.05, label: "Tối đa" }),
},
plot: (d, p) => {
const sar = ta.psar(d, p.step, p.max);
const duoiGia = sar.lt(d.close);
return {
SAR: line(sar, { points: "circles", colors: [{ when: duoiGia, color: "up" }], color: "down" }),
"Đảo lên": shape(duoiGia.and(duoiGia.shift(1).fillna(1).not()), { at: "below", shape: "arrowUp", color: "up" }),
"Đảo xuống": shape(duoiGia.not().and(duoiGia.shift(1).fillna(0)), { at: "above", shape: "arrowDown", color: "down" }),
};
},
});
线性回归通道
100 根 K 线的回归线以及 ± 2 个标准差的通道(库中的 linreg-channel 指标),并附带斜率,用来判断趋势强弱。
indicator({
name: "Kênh hồi quy",
pane: "price",
params: {
n: param.int(100, { min: 20, max: 300, label: "Số nến" }),
dev: param.num(2, { min: 1, max: 4, step: 0.5, label: "Độ lệch chuẩn" }),
},
plot: (d, p) => {
const k = ta.run("linreg-channel", { n: p.n, dev: p.dev });
const doc = ta.slope(d.close, p.n).div(d.close).mul(100);
return {
"Kênh": band(k.upper, k.lower, { color: "accent", opacity: 0.06 }),
"Hồi quy": line(k.mid, { color: "accent", dash: "dash" }),
"Độ dốc %/nến": line(doc, { pane: "Độ dốc", color: "ai", format: "number" }),
"0": hline(0, { pane: "Độ dốc" }),
};
},
});
Aroon
Aroon Up / Down 衡量自 n 根 K 线高点 / 低点以来经过的 K 线数。Up 高于 70 且 Down 低于 30 表示明确的上升趋势。
indicator({
name: "Aroon",
scale: { range: [0, 100], levels: [30, 70] },
params: { n: param.int(25, { min: 5, max: 100, label: "Chu kỳ" }) },
plot: (d, p) => {
const a = ta.run("aroon", { n: p.n });
return {
"Aroon Up": line(a.up, { color: "up" }),
"Aroon Down": line(a.down, { color: "down" }),
"Up cắt lên Down": shape(a.up.crossAbove(a.down), { at: "bottom", shape: "triangleUp", color: "up" }),
};
},
});
唐奇安通道与突破
库中的 Kênh Donchian và bứt phá(唐奇安通道与突破)模板:由之前 n 根 K 线(不含当前 K 线)的高点 / 低点构成的通道,收盘价突破通道上轨时显示旗标。
indicator({
name: "Kênh Donchian và bứt phá",
pane: "price",
params: { n: param.int(20, { min: 5, max: 200, label: "Số nến" }) },
plot: (d, p) => {
const hi = d.high.highest(p.n).shift(1);
const lo = d.low.lowest(p.n).shift(1);
return {
Kênh: band(hi, lo, { color: "ref", opacity: 0.08 }),
"Đỉnh kênh": line(hi, { color: "up", dash: "dash" }),
"Đáy kênh": line(lo, { color: "down", dash: "dash" }),
"Bứt phá": shape(d.close.crossAbove(hi), { at: "below", shape: "flag", color: "up" }),
};
},
alerts: (d, p) => ({ "Giá vượt đỉnh kênh": d.close.crossAbove(d.high.highest(p.n).shift(1)) }),
});
三周期趋势:日、周、月
一个小窗格,三行圆点:价格高于该周期的 EMA 20 时为绿色,低于时为红色。快速判断“各周期是否一致”。
indicator({
name: "Xu hướng ba khung",
scale: { range: [0, 4] },
plot: (d) => {
const tren = (b) => b.close.gt(ta.ema(b.close, 20));
const hang = (dk, muc) => d.const(muc).where(dk.notNaN());
const ngay = tren(d);
const tuan = tren(d.tf("1W"));
const thang = tren(d.tf("1M"));
return {
"Ngày": shape(ngay.notNaN(), { at: "value", value: hang(ngay, 3), shape: "circle", size: "s", colors: [{ when: ngay, color: "up" }], color: "down" }),
"Tuần": shape(tuan.notNaN(), { at: "value", value: hang(tuan, 2), shape: "circle", size: "s", colors: [{ when: tuan, color: "up" }], color: "down" }),
"Tháng": shape(thang.notNaN(), { at: "value", value: hang(thang, 1), shape: "circle", size: "s", colors: [{ when: thang, color: "up" }], color: "down" }),
};
},
alerts: (d) => {
const tren = (b) => b.close.gt(ta.ema(b.close, 20));
return { "Cả ba khung trên EMA 20": tren(d).and(tren(d.tf("1W"))).and(tren(d.tf("1M"))) };
},
});
tren 是一个您自己的函数,接收数据(日、周或月)并返回条件——写一次,用三次。