本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("Solar Numbers (666/111/36/6)", overlay=true, max_lines_count=50, max_labels_count=50)
// ── Anchor price ──────────────────────────────────────────────
// Click the little target icon next to this input on the chart
// to set it with your crosshair, or type a value directly.
anchor = input.price(defval=100000, title="Anchor Price", confirm=true)
// ── Which solar numbers to show ──────────────────────────────
show666 = input.bool(true, "Show 666")
show111 = input.bool(true, "Show 111")
show36 = input.bool(true, "Show 36")
show6 = input.bool(true, "Show 6")
extendRight = input.bool(true, "Extend lines into future")
ext = extendRight ? extend.right : extend.none
col666 = input.color(color.red, "666 colour")
col111 = input.color(color.orange, "111 colour")
col36 = input.color(color.yellow, "36 colour")
col6 = input.color(color.aqua, "6 colour")
lineWidth = input.int(1, "Line width", minval=1, maxval=4)
// ── Plot a level pair (anchor + n, anchor - n) once per anchor change ──
var line hi666 = na
var line lo666 = na
var line hi111 = na
var line lo111 = na
var line hi36 = na
var line lo36 = na
var line hi6 = na
var line lo6 = na
var label lbl_hi666 = na
var label lbl_lo666 = na
var label lbl_hi111 = na
var label lbl_lo111 = na
var label lbl_hi36 = na
var label lbl_lo36 = na
var label lbl_hi6 = na
var label lbl_lo6 = na
f_drawLevel(_lineRef, _labelRef, _price, _txt, _col) =>
line.delete(_lineRef)
label.delete(_labelRef)
newLine = line.new(bar_index, _price, bar_index + 1, _price, extend=ext, color=_col, width=lineWidth)
newLabel = label.new(bar_index, _price, _txt + " " + str.tostring(_price, format.mintick), style=label.style_label_left, color=color.new(_col, 80), textcolor=_col, size=size.small)
[newLine, newLabel]
if barstate.islast
if show666
[l1, b1] = f_drawLevel(hi666, lbl_hi666, anchor + 666, "666", col666)
hi666 := l1
lbl_hi666 := b1
[l2, b2] = f_drawLevel(lo666, lbl_lo666, anchor - 666, "-666", col666)
lo666 := l2
lbl_lo666 := b2
if show111
[l3, b3] = f_drawLevel(hi111, lbl_hi111, anchor + 111, "111", col111)
hi111 := l3
lbl_hi111 := b3
[l4, b4] = f_drawLevel(lo111, lbl_lo111, anchor - 111, "-111", col111)
lo111 := l4
lbl_lo111 := b4
if show36
[l5, b5] = f_drawLevel(hi36, lbl_hi36, anchor + 36, "36", col36)
hi36 := l5
lbl_hi36 := b5
[l6, b6] = f_drawLevel(lo36, lbl_lo36, anchor - 36, "-36", col36)
lo36 := l6
lbl_lo36 := b6
if show6
[l7, b7] = f_drawLevel(hi6, lbl_hi6, anchor + 6, "6", col6)
hi6 := l7
lbl_hi6 := b7
[l8, b8] = f_drawLevel(lo6, lbl_lo6, anchor - 6, "-6", col6)
lo6 := l8
lbl_lo6 := b8