Indicator · Pine Script v6 · On the chart

Scale Binding POC

by tc3oliver

A diagnostic proof-of-concept that checks which price scale chart drawings attach to.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code115
Settings2inputs
LicenceMPL-2.0
Last update7 weeks ago10 Sep 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

115 lines of Pine Script v6 from btc-trading-assistant/poc/scale-binding-poc.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

scale-binding-poc.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tc3oliver

//@version=6

// ============================================================================
// PRICE-SCALE BINDING POC — not part of the product
//
// WHY THIS FILE EXISTS
// A screenshot showed the panel printing STOP 72,940.9 while the stop line sat
// near 65k of chart height. Two mechanisms could put a price level at the wrong
// height, and they need different fixes:
//
//   1. The indicator instance is bound to the wrong price scale. Then EVERY
//      visual it owns is wrong together, and force_overlay may or may not
//      exempt drawings from it — the documentation does not say.
//   2. input.price()'s own horizontal marker is positioned independently of the
//      line this script draws. Then the two disagree with each other, and no
//      Pine parameter controls the marker.
//
// This file makes both visible at once, on one chart, so the answer comes from
// looking rather than from reasoning about documentation.
//
// HOW TO RUN IT
//   1. Open BINANCE:BTCUSDT.P, 4H.
//   2. Add this script. Leave both test prices at their defaults, or set them to
//      a round number well away from current price so a mismatch is obvious.
//   3. Look at the four visuals listed under WHAT YOU SHOULD SEE below.
//   4. Then right-click the script's name in the legend → Pin to Scale → No
//      Scale, and look again. That is the hostile state, and it is the whole
//      point of the POC.
//
// WHAT YOU SHOULD SEE, and what each outcome means
//
//   A  force_overlay line        at TEST PRICE A
//   B  plain line, no parameter  at TEST PRICE A   (same price, drawn twice)
//   C  input.price marker        at TEST PRICE B   (TradingView's, not ours)
//   D  force_overlay line        at TEST PRICE B   (ours, same price as C)
//
//   A == B, both correct, in both the normal and the No Scale state
//        → force_overlay changes nothing, and drawings are never affected by the
//          instance's scale pin. The bug is not here.
//   A correct, B wrong, in the No Scale state
//        → force_overlay DOES re-bind a drawing to the main pane's scale. This is
//          the outcome that would make force_overlay a real fix rather than a
//          hedge, and the product already carries it.
//   A == B, both wrong, in the No Scale state
//        → the scale pin governs all drawings and Pine cannot override it. The
//          only fix is the chart's Pin to Scale setting, and the product must say
//          so rather than pretend.
//   C and D at different heights, in ANY state
//        → input.price's marker is not bound to the same scale as the line, and
//          since no Pine parameter controls it, a product that uses input.price
//          can show two stops at once. The shipped script therefore uses
//          input.float for every price the user enters.
//
// Record the four outcomes in TRADINGVIEW-VALIDATION.md items 47-50.
// ============================================================================

indicator("Scale Binding POC", overlay = true, max_lines_count = 10, max_labels_count = 10)

// Deliberately NOT input.price, so this one cannot itself add a marker and
// confuse the comparison.
pA = input.float(0.0, "TEST PRICE A (0 = close - 5%)", minval = 0, group = "POC")
// Deliberately input.price, because its marker is one of the four things under
// test. This is the only input.price in the repository and it lives here on
// purpose.
pB = input.price(0.0, "TEST PRICE B — input.price, watch its marker", group = "POC")

a = pA > 0 ? pA : close * 0.95
b = pB > 0 ? pB : close * 1.05

var line lA = na
var line lB = na
var line lD = na
var label tA = na
var label tB = na
var label tD = na

if barstate.islast
    x1 = time - 30 * (timeframe.in_seconds() * 1000)
    x2 = time

    // A: ours, force_overlay. B: ours, no parameter at all. Same price.
    // If A and B ever render at different heights, force_overlay governs scale.
    if na(lA)
        lA := line.new(x1, a, x2, a, xloc = xloc.bar_time, extend = extend.both, color = color.lime, width = 2, force_overlay = true)
        tA := label.new(x2, a, "A  force_overlay  " + str.tostring(a, "#.##"), xloc = xloc.bar_time, style = label.style_label_left, color = color.new(color.lime, 20), textcolor = color.black, force_overlay = true)
    if na(lB)
        lB := line.new(x1, a, x2, a, xloc = xloc.bar_time, extend = extend.both, color = color.orange, style = line.style_dashed, width = 1)
        tB := label.new(x1, a, "B  no force_overlay  " + str.tostring(a, "#.##"), xloc = xloc.bar_time, style = label.style_label_right, color = color.new(color.orange, 20), textcolor = color.black)
    // D: ours, at the same price as the input.price marker C.
    // If C and D disagree, the marker is not on the line's scale.
    if na(lD)
        lD := line.new(x1, b, x2, b, xloc = xloc.bar_time, extend = extend.both, color = color.fuchsia, width = 2, force_overlay = true)
        tD := label.new(x2, b, "D  ours, = C's price  " + str.tostring(b, "#.##"), xloc = xloc.bar_time, style = label.style_label_left, color = color.new(color.fuchsia, 20), textcolor = color.white, force_overlay = true)

    line.set_xy1(lA, x1, a)
    line.set_xy2(lA, x2, a)
    label.set_xy(tA, x2, a)
    label.set_text(tA, "A  force_overlay  " + str.tostring(a, "#.##"))
    line.set_xy1(lB, x1, a)
    line.set_xy2(lB, x2, a)
    label.set_xy(tB, x1, a)
    label.set_text(tB, "B  no force_overlay  " + str.tostring(a, "#.##"))
    line.set_xy1(lD, x1, b)
    line.set_xy2(lD, x2, b)
    label.set_xy(tD, x2, b)
    label.set_text(tD, "D  ours, = C's price  " + str.tostring(b, "#.##"))

// A real price series, so there is something plotted to right-click for the
// Pin to Scale menu, and something that is unambiguously on the main scale to
// compare everything else against. The shipped product's only plot is na by
// default, which is why its scale menu can be hard to reach.
plot(close, "close (reference, definitely on the main scale)", color = color.new(color.blue, 60))

Overview

Scale Binding POC draws lines on the price chart at one test price using a forced-overlay setting and again without it, and compares them with the marker TradingView adds for a price input. The author uses it to see whether pinning the indicator to no scale moves its drawings. It has two test price inputs, gives no trading signals and is not meant for analysis.

Details

Published by

tc3oliver on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Markets

Crypto

Timeframes

H4 and above

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingictpine-scriptpinescriptsmctrading-indicatortradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
TEST PRICE A (0 = close - 5%)float0.0pA
TEST PRICE B — input.price, watch its markerprice0.0pB
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

948 stars

The Adaptive Laguerre Filter calculates a smoothed, dynamically adjusted trendline plotted directly on the main price chart. It dynamically adjusts its damping factor (alpha) based on recent price range variations and median percentile calculations over a spec

Indicator v4 TrendMoving averages
Updated 11 days ago · GPL-3.0 GitHub repository of Adaptive Laguerre Filter
575 stars

The indicator plots ICT displacement candles on the price chart and can switch to retracement scanning. Displacement requires a move larger than a set share of the 14-bar average high-low range, lasting at least a chosen number of bars, with optional close, pr

Indicator v6 SMC / ICT / price actionCandlestick patterns
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Displacement Candles Indicator
330 stars

This script plots three moving averages on the price chart: a fast EMA or SMA with 10 periods, a slow EMA or SMA with 20 periods, and a trend EMA or SMA with 100 periods. It signals trend changes by drawing a white cross when the fast moving average crosses ab

Indicator v4 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of 3 EMA/SMA + Cross [Alorse]
318 stars

This indicator calculates an ATR trailing stop line derived from the highest high minus an average true range multiple over a specified lookback period. It plots the trailing stop line directly on the price chart and colors price bars based on whether the clos

Indicator v5 TrendVolatility & bands
Updated 2 months ago · MIT GitHub repository of ATR Trailing Stoploss

1833 Tracker

by Allen1212
303 stars

1833 Tracker is an overlay indicator that visualizes historical buy and sell transactions executed by ARK Invest ETFs for the stock on the main price chart. It displays trade dates using green buy and red sell labels positioned relative to price bars, indicati

Indicator v4
Updated 2 years ago · None stated GitHub repository of 1833 Tracker

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers