//@version=6 indicator("Supertrend Visual Bridge v0.4", shorttitle="ST Bridge v3", overlay=true) // Standard TradingView Supertrend formula, using confirmed candle flips. atrLength = input.int(10, "ATR Length", minval=1) factor = input.float(3.0, "Supertrend Factor", minval=0.1, step=0.1) showTradeLabels = input.bool(true, "Show LONG / SHORT labels") [st, direction] = ta.supertrend(factor, atrLength) plot(direction < 0 ? st : na, "Uptrend", color=color.green, linewidth=2, style=plot.style_linebr) plot(direction > 0 ? st : na, "Downtrend", color=color.red, linewidth=2, style=plot.style_linebr) // Confirmed flips are real trading conditions. This script never places a trade by itself. bool longFlip = direction[1] > 0 and direction < 0 bool shortFlip = direction[1] < 0 and direction > 0 plotshape(showTradeLabels and longFlip and barstate.isconfirmed, "LONG", shape.labelup, location.belowbar, color=color.green, text="LONG", textcolor=color.white, size=size.tiny) plotshape(showTradeLabels and shortFlip and barstate.isconfirmed, "SHORT", shape.labeldown, location.abovebar, color=color.red, text="SHORT", textcolor=color.white, size=size.tiny) // DROP-IN VISUAL BRIDGE (Pine Script v6), protocol v3. // Paste this BELOW your own indicator/strategy signal calculations. // Do not copy an extra //@version, indicator() or strategy() declaration. // EDIT ONLY THE FOUR CONDITION LINES BELOW for each new script. // Set true only when the existing strategy/indicator *confirms* the condition. // Examples: bridgeOpenLong = buyCondition, bridgeOpenShort = sellCondition // For strategies, map explicit entry/exit intent rather than a colored plot. bool bridgeOpenLong = longFlip bool bridgeOpenShort = shortFlip bool bridgeCloseLong = false // TODO optional: close long condition bool bridgeCloseShort = false // TODO optional: close short condition int bridgeChannel = input.int(7, "Visual bridge channel", minval=0, maxval=255) string bridgeSymbolOverride = input.string("", "Bridge symbol override (blank = chart base+quote)") string bridgeSymbol = str.length(bridgeSymbolOverride) > 0 ? str.upper(bridgeSymbolOverride) : str.upper(syminfo.basecurrency + syminfo.currency) string bridgeTestAction = input.string("Off", "VISUAL TEST (never sends Binance orders)", options=["Off","TEST_LONG","TEST_SHORT","TEST_CLOSE_LONG","TEST_CLOSE_SHORT"]) var int bridgeAction = 0 var int bridgeSignalTime = 0 var int bridgeTestStamp = int(timenow / 1000) // fixed at script load; input edits re-run the script if barstate.isconfirmed and not na(time_close) int incomingAction = 0 if bridgeOpenLong incomingAction := 1 else if bridgeOpenShort incomingAction := 2 else if bridgeCloseLong incomingAction := 3 else if bridgeCloseShort incomingAction := 4 if incomingAction != 0 bridgeAction := incomingAction bridgeSignalTime := int(time_close / 1000) // Test codes 5-8 are displayed immediately after changing this Pine input. // They can be decoded by Chrome but must NEVER execute exchange orders. // The stamp stays constant through realtime updates to avoid repeated test signals. if barstate.islast and bridgeTestAction != "Off" bridgeAction := bridgeTestAction == "TEST_LONG" ? 5 : bridgeTestAction == "TEST_SHORT" ? 6 : bridgeTestAction == "TEST_CLOSE_LONG" ? 7 : 8 bridgeSignalTime := bridgeTestStamp // Visual protocol v3: 19 colored cells, left-to-right: // [MAGENTA start][CYAN start][version][action][8 hex nibbles UNIX seconds] // [2 hex nibbles channel][4 symbol hash hex nibbles][1 checksum]. No OCR/TV alerts. // The 16-color palette MUST match extension/decoder.js exactly. bridgeHexNibble(int value, int shift) => int(math.floor(value / math.pow(16, shift))) % 16 bridgeHexColor(int n) => switch n 0 => #1A1A1A 1 => #E53935 2 => #43A047 3 => #1E88E5 4 => #FDD835 5 => #8E24AA 6 => #FB8C00 7 => #00ACC1 8 => #D81B60 9 => #7CB342 10 => #3949AB 11 => #6D4C41 12 => #90A4AE 13 => #C0CA33 14 => #5E35B1 15 => #F4511E => color.gray bridgeSymbolFingerprint(string ticker) => string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" string upperTicker = str.upper(ticker) int hash = 0 for i = 0 to str.length(upperTicker) - 1 string ch = str.substring(upperTicker, i, i + 1) hash := (hash * 17 + str.pos(alphabet, ch) + 1) % 65536 hash var table bridgeDisplay = table.new(position.top_right, 19, 1, frame_width=0, border_width=0) if barstate.islast int contractHash = bridgeSymbolFingerprint(bridgeSymbol) int checksum = (3 + bridgeAction + bridgeHexNibble(bridgeChannel, 1) + bridgeHexNibble(bridgeChannel, 0)) % 16 for i = 0 to 7 checksum := (checksum + bridgeHexNibble(bridgeSignalTime, i)) % 16 for i = 0 to 3 checksum := (checksum + bridgeHexNibble(contractHash, i)) % 16 for col = 0 to 18 int code = 0 if col == 2 code := 3 else if col == 3 code := bridgeAction else if col >= 4 and col <= 11 code := bridgeHexNibble(bridgeSignalTime, 11 - col) else if col == 12 code := bridgeHexNibble(bridgeChannel, 1) else if col == 13 code := bridgeHexNibble(bridgeChannel, 0) else if col >= 14 and col <= 17 code := bridgeHexNibble(contractHash, 17 - col) else if col == 18 code := checksum color fill = col == 0 ? #FF00FF : col == 1 ? #00FFFF : bridgeHexColor(code) table.cell(bridgeDisplay, col, 0, "", width=2.0, height=4.0, bgcolor=fill)