Traders Creed

D-Khoduase · study · 97 行 · 点赞 6 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
// ═══════════════════════════════════════════════════════════════════════════════
// THE CREED  ·  v1.5  ·  Boss Gbini
//
// Two bullets. A sniper does not spray the market — he lies still, reads the
// wind, and fires only when the shot is there. This indicator draws nothing on
// price and reads nothing from it. It sits in the corner of the chart as the
// reminder: WAIT FOR THE RIGHT TIME.
//
// Drawn as block-character art in a table cell (monospace), so it stays fixed
// on screen whatever the zoom or scroll. Spaces are non-breaking so the
// silhouette keeps its shape.
//
// v1.1 · both bullets stamped from one pixel template — twins; a one-pixel gap
// carved around the rifle where it crosses the shooter, so the stock, receiver
// and scope read against his shoulder and head.
// v1.2 · the feet turned the right way — toes down, as a prone shooter lies.
// v1.3 · the creed line takes its own size, colour and offsets — sideways in
// characters, up or down in lines, above or below the sniper.
// v1.4 · MICRO size — half of Tiny — for the sniper and the creed line.
// v1.5 · MINI size (between Micro and Tiny); horizontal and vertical offsets for
// the sniper, the creed line riding along with him.
// ═══════════════════════════════════════════════════════════════════════════════
indicator("The Creed", "The Creed", overlay = true)
 
string G = "🎯 The Creed"
string c_pos  = input.string("Bottom Right", "Position",
     options = ["Top Left", "Top Centre", "Top Right", "Middle Left", "Middle Centre", "Middle Right", "Bottom Left", "Bottom Centre", "Bottom Right"], group = G)
string c_sz   = input.string("Small", "Size", options = ["Micro", "Mini", "Tiny", "Small", "Normal", "Large", "Huge"], group = G)
float  c_h    = input.float(0.0, "Horizontal offset", -50.0, 50.0, step = 0.5, group = G,
     tooltip = "Moves the sniper — and the creed line with him — in % of the chart's width. + right, − left, measured from the corner chosen in Position. A nudge towards the edge he already sits on has nowhere to go.")
float  c_v    = input.float(0.0, "Vertical offset", -50.0, 50.0, step = 0.5, group = G,
     tooltip = "Moves the sniper — and the creed line with him — in % of the chart's height. + up, − down, measured from the corner chosen in Position.")
color  c_col  = input.color(color.new(color.white, 0), "Silhouette", group = G,
     tooltip = "White by default. Raise the colour's transparency to sink it into the background.")
string GL = "📜 Creed Line"
bool   c_line  = input.bool(true, "Creed line", inline = "cl", group = GL)
string c_text  = input.string("TWO BULLETS · WAIT FOR THE SHOT", "", inline = "cl", group = GL)
string c_lsz   = input.string("Small", "Size", options = ["Micro", "Mini", "Tiny", "Small", "Normal", "Large", "Huge"], inline = "cl2", group = GL)
color  c_lcol  = input.color(color.new(color.white, 0), "Colour", inline = "cl2", group = GL)
int    c_lh    = input.int(0, "Horizontal offset (characters)", -40, 40, group = GL,
     tooltip = "0 = centred under the sniper. + moves the line right, − moves it left, one character of the line's own font per step.")
int    c_lv    = input.int(0, "Vertical offset (lines)", -10, 10, group = GL,
     tooltip = "0 = directly under the sniper. + moves the line further down, one line per step. − moves it up: −1 puts it directly above the sniper, −2 one line above that, and so on.")
 
f_pos(string p) =>
    p == "Top Left" ? position.top_left : p == "Top Centre" ? position.top_center : p == "Top Right" ? position.top_right :
     p == "Middle Left" ? position.middle_left : p == "Middle Centre" ? position.middle_center : p == "Middle Right" ? position.middle_right :
     p == "Bottom Left" ? position.bottom_left : p == "Bottom Centre" ? position.bottom_center : position.bottom_right
f_sz(string s) => s == "Tiny" ? size.tiny : s == "Small" ? size.small : s == "Large" ? size.large : s == "Huge" ? size.huge : size.normal
// MICRO and MINI sit below the named sizes, so they are given in typographic
// points instead — Micro half of Tiny, Mini between the two. table.cell takes
// either form, so each cell has a points branch.
f_pt(string s) => s == "Micro" ? 4 : s == "Mini" ? 6 : 0
string TIP = "THE CREED\n\nI carry two bullets.\nI do not chase. I do not spray.\nI wait for the sweep, the story and the level.\nWhen the shot is there, I take it once — and I let it work."
 
string ART = "                                       ▄███▄                                                       \n                                     ▄▄█████▄                                        █           █ \n                                    ▀▀▀█████ ▄█▄▄▄▄▄▄▄▄▄                            ▄█▄         ▄█▄\n                                       ███▀▀ ████▀▀▀█▀▀▀                      ▀▀▀▀▀ ███   ▀▀▀▀▀ ███\n                                   ▄▄ ▄▄▄▄▄████████████▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄███     ▀▀▀▀ ███    ▀▀▀▀ ███\n                         ▄▄▄▄▄███████▄ █████▀▀▀▀▀▀▀▀▀▀▀▀      ▄█▄      ▀▀▀      ▀▀▀ ███     ▀▀▀ ███\n                ▄▄▄▄▄█████████████████ ▀▀▀▀ ▄██               █▀█                    █           █ \n▄▄▄▄▄▄████████████████████████████████████▄▄██               █▀ ▀█                   ▀           ▀ \n███████████▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀  ▀▀█▀▀               ▄█   █▄                                \n███▀                                                        ▀     ▀                                \n ▀▀                                                                                                "
 
// Layout · 3 × 5. Column 1 holds the insignia: row 1 the creed line when it sits
// above, row 2 the sniper, row 3 the creed line when it sits below. The sniper's
// offsets are empty spacer cells around that column — a spacer on the left pushes
// the block right, on the right pushes it left, below lifts it, above lowers it.
// The creed line's offsets are padding inside its own cell: non-breaking spaces
// to slide it sideways (a centred cell moves by half the padding, so it is
// doubled), blank lines to open the gap.
var table t = table.new(position.bottom_right, 3, 5)
if barstate.islast
    table.clear(t, 0, 0, 2, 4)
    table.set_position(t, f_pos(c_pos))
    if c_h > 0
        table.cell(t, 0, 2, "", width = c_h)
    if c_h < 0
        table.cell(t, 2, 2, "", width = -c_h)
    if c_v < 0
        table.cell(t, 1, 0, "", height = -c_v)
    if c_v > 0
        table.cell(t, 1, 4, "", height = c_v)
    if f_pt(c_sz) > 0
        table.cell(t, 1, 2, ART, text_color = c_col, text_size = f_pt(c_sz), text_halign = text.align_left,
             text_font_family = font.family_monospace, tooltip = TIP)
    else
        table.cell(t, 1, 2, ART, text_color = c_col, text_size = f_sz(c_sz), text_halign = text.align_left,
             text_font_family = font.family_monospace, tooltip = TIP)
    if c_line
        string nb  = " "
        string pad = str.repeat(nb, 2 * math.abs(c_lh))
        string txt = c_lh > 0 ? pad + c_text : c_lh < 0 ? c_text + pad : c_text
        bool   up  = c_lv < 0
        int    gap = up ? -c_lv - 1 : c_lv
        string blk = gap > 0 ? str.repeat(nb, gap, "\n") : ""   // the blank lines
        string out = up ? txt + (gap > 0 ? "\n" + blk : "") : (gap > 0 ? blk + "\n" : "") + txt
        if f_pt(c_lsz) > 0
            table.cell(t, 1, up ? 1 : 3, out, text_color = c_lcol, text_size = f_pt(c_lsz), text_halign = text.align_center,
                 text_font_family = font.family_monospace)
        else
            table.cell(t, 1, up ? 1 : 3, out, text_color = c_lcol, text_size = f_sz(c_lsz), text_halign = text.align_center,
                 text_font_family = font.family_monospace)

← 返回列表