Chuyển đến nội dung chính
ATK Pine Script®

Các Mẫu Fill

fill, linefill.new, và ctx.atk.fill_between — chọn đúng API fill dựa trên việc line là khai báo tĩnh hay ATK bridge line.

Các Mẫu Fill và Zone#

Nhu cầuAPI khuyến nghịLý do
fill giữa hai line tĩnhfill(...) hoặc linefill.new(...)Dùng khi các line đã tồn tại dưới dạng khai báo tĩnh.
fill giữa các ATK bridge linectx.atk.fill_between(...)Dùng khi các line được tạo qua ctx.atk.plot_line.
Nhóm zone hoặc họ hình chữ nhậtctx.atk.rectangles(...) hoặc bridge helper liên quanDùng khi visual giống vùng nhóm hơn là cặp line.

Không khớp danh tính: ctx.atk.fill_between fill giữa các bridge line key, không phải key plot tĩnh. Cố gắng trộn hai loại danh tính sẽ không hoạt động như mong đợi. Hãy khớp API fill với API đã tạo ra các line.

Mẫu fill_between đúng#

# Wrong: trying to fill between static keys with the bridge helper.
# ctx.atk.fill_between(line1="bb_upper", line2="bb_lower", ...)

# Right: bridge fills between bridge line keys.
ctx.atk.plot_line(key="fast_line", source="fast", color="#00c853")
ctx.atk.plot_line(key="slow_line", source="slow", color="#f23645")
ctx.atk.fill_between(key="trend_fill", line1="fast_line", line2="slow_line", fill_alpha=24)

Mẫu fill tĩnh đúng#

# Declare two plot lines at the script level.
plot("bb_upper", key="bb_upper", title="Upper Band", color="#2962ff")
plot("bb_lower", key="bb_lower", title="Lower Band", color="#2962ff")

# Fill between them using the static fill API.
fill("bb_upper", "bb_lower", color="#2962ff20", title="BB Fill")