Indicator · Pine Script v6 · On the chart

Custom Synthetic Smooth Price Line

by shubhamtaywade82· code credited to nemesis

Draws a customisable horizontal price line on the chart that follows the current price, with an optional secondary line.

View on GitHub

Repaints Archived by its author

GitHub stars1on the repository
Pine versionv6current
Lines of code160
Settings24inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago31 May 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

160 lines of Pine Script v6 from indicators/utilities/synthetic-smooth-price-line.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

synthetic-smooth-price-line.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © nemesis

//@version=6
indicator(
     title="Custom Synthetic Smooth Price Line",
     shorttitle="SynthLine",
     overlay=true,
     max_lines_count=2
)

// ─────────────────────────────────────────────────────────────
// PRICE LINE INPUTS
// ─────────────────────────────────────────────────────────────

lineModeInput = input.string(title="Color Mode", defval="Candles", options=["Default", "Candles"], group="Price Line")
lineColorDefaultInput = input.color(color.silver, "Default", group="Price Line")
lineColorRisingInput = input.color(#089981, "Candles Rising", group="Price Line")
lineColorFallingInput = input.color(#f23645, "Candles Falling", group="Price Line")
lineStyleInput = input.string(title="Style", defval="Dotted", options=["Dotted", "Dashed", "Solid"], group="Price Line")
lineThicknessInput = input.string(title="Thickness", defval="1", options=["1", "2", "3", "4"], group="Price Line")
lineLengthInput = input.int(title="Length (bars)", minval=0, maxval=500, defval=150, group="Price Line")
lineExtendLeftInput = input.bool(false, "Extend Left", group="Price Line")
lineExtendRightInput = input.bool(true, "Extend Right", group="Price Line")

// ─────────────────────────────────────────────────────────────
// SECONDARY LINE INPUTS
// ─────────────────────────────────────────────────────────────

secondLineShowInput = input.bool(true, "Show Secondary Line", group="Secondary Line")
secondLineModeInput = input.string(title="Color Mode", defval="Default", options=["Default", "Candles"], group="Secondary Line")
secondLineColorDefaultInput = input.color(color.new(color.silver, 30), "Default", group="Secondary Line")
secondLineColorRisingInput = input.color(color.new(#089981, 50), "Candles Rising", group="Secondary Line")
secondLineColorFallingInput = input.color(color.new(#f23645, 50), "Candles Falling", group="Secondary Line")
secondLineStyleInput = input.string(title="Style", defval="Dashed", options=["Dotted", "Dashed", "Solid"], group="Secondary Line")
secondLineThicknessInput = input.string(title="Thickness", defval="1", options=["1", "2", "3", "4"], group="Secondary Line")
secondLineLengthInput = input.int(title="Length (bars)", minval=0, maxval=500, defval=0, group="Secondary Line")
secondLineExtendLeftInput = input.bool(true, "Extend Left", group="Secondary Line")
secondLineExtendRightInput = input.bool(false, "Extend Right", group="Secondary Line")

// ─────────────────────────────────────────────────────────────
// SYNTHETIC MOVEMENT INPUTS
// ─────────────────────────────────────────────────────────────

enableSyntheticInput = input.bool(true, "Enable Synthetic Movement", group="Synthetic Movement")
subTickDivisor = input.int(100, "Sub-Tick Divisions", minval=2, maxval=1000, step=10, group="Synthetic Movement", tooltip="Splits each mintick into N micro-steps. e.g. mintick=0.01, divisions=100 → step=0.0001. Higher = smoother, slower catch-up.")
showDotInput = input.bool(false, "Show Dot", group="Synthetic Movement")
dotColorInput = input.color(color.black, "Dot Color", group="Synthetic Movement")
dotSizeInput = input.string("Tiny", "Dot Size", options=["Auto", "Tiny", "Small"], group="Synthetic Movement")

// ─────────────────────────────────────────────────────────────
// STYLE MAPPING (no `var` — must recalculate on input change)
// ─────────────────────────────────────────────────────────────

lineStyle = switch lineStyleInput
    "Solid"  => line.style_solid
    "Dotted" => line.style_dotted
    => line.style_dashed

lineThickness = switch lineThicknessInput
    "2" => 2
    "3" => 3
    "4" => 4
    => 1

lineExtension = lineExtendLeftInput and lineExtendRightInput ? extend.both : lineExtendLeftInput ? extend.left : lineExtendRightInput ? extend.right : extend.none

secondLineStyle = switch secondLineStyleInput
    "Solid"  => line.style_solid
    "Dotted" => line.style_dotted
    => line.style_dashed

secondLineThickness = switch secondLineThicknessInput
    "2" => 2
    "3" => 3
    "4" => 4
    => 1

secondLineExtension = secondLineExtendLeftInput and secondLineExtendRightInput ? extend.both : secondLineExtendLeftInput ? extend.left : secondLineExtendRightInput ? extend.right : extend.none

mainLength = math.max(lineLengthInput, 1)
secondLength = math.max(secondLineLengthInput, 1)

// ─────────────────────────────────────────────────────────────
// SYNTHETIC SMOOTH PRICE ENGINE
//
// Pure linear stepper: each realtime tick moves `price` by
// exactly (mintick × stepsPerTick) toward close.
//   e.g. mintick=0.01, stepsPerTick=1 →
//        100.00 → 100.01 → 100.02 → ... → 100.50
// ─────────────────────────────────────────────────────────────

varip float price = na

if na(price)
    price := close

stepSize = syminfo.mintick / subTickDivisor
targetPrice = close
delta = targetPrice - price
distance = math.abs(delta)

if barstate.islast and enableSyntheticInput
    if distance > stepSize
        price := delta > 0 ? price + stepSize : price - stepSize
    else
        price := targetPrice

if not enableSyntheticInput
    price := close

// ─────────────────────────────────────────────────────────────
// COLOR ENGINE
// ─────────────────────────────────────────────────────────────

lineColor = lineModeInput == "Candles" ? (price >= open ? lineColorRisingInput : lineColorFallingInput) : lineColorDefaultInput

secondLineColor = secondLineModeInput == "Candles" ? (price >= open ? secondLineColorRisingInput : secondLineColorFallingInput) : secondLineColorDefaultInput

// ─────────────────────────────────────────────────────────────
// MAIN PRICE LINE
// ─────────────────────────────────────────────────────────────

var line priceLine = na

if barstate.islast
    if na(priceLine)
        priceLine := line.new(x1=bar_index - mainLength, y1=price, x2=bar_index, y2=price, xloc=xloc.bar_index, extend=lineExtension, color=lineColor, style=lineStyle, width=lineThickness)
    else
        line.set_xy1(priceLine, bar_index - mainLength, price)
        line.set_xy2(priceLine, bar_index, price)
        line.set_color(priceLine, lineColor)
        line.set_style(priceLine, lineStyle)
        line.set_width(priceLine, lineThickness)
        line.set_extend(priceLine, lineExtension)

// ─────────────────────────────────────────────────────────────
// SECONDARY LINE
// ─────────────────────────────────────────────────────────────

var line secondPriceLine = na

if barstate.islast and secondLineShowInput
    if na(secondPriceLine)
        secondPriceLine := line.new(x1=bar_index - secondLength, y1=price, x2=bar_index, y2=price, xloc=xloc.bar_index, extend=secondLineExtension, color=secondLineColor, style=secondLineStyle, width=secondLineThickness)
    else
        line.set_xy1(secondPriceLine, bar_index - secondLength, price)
        line.set_xy2(secondPriceLine, bar_index, price)
        line.set_color(secondPriceLine, secondLineColor)
        line.set_style(secondPriceLine, secondLineStyle)
        line.set_width(secondPriceLine, secondLineThickness)
        line.set_extend(secondPriceLine, secondLineExtension)

// ─────────────────────────────────────────────────────────────
// OPTIONAL DOT (separate plotchar per size — `size` must be const)
// ─────────────────────────────────────────────────────────────

plotchar(showDotInput and dotSizeInput == "Auto" ? price : na, title="Price Dot Auto", location=location.absolute, char="•", color=dotColorInput, size=size.auto)
plotchar(showDotInput and dotSizeInput == "Tiny" ? price : na, title="Price Dot Tiny", location=location.absolute, char="•", color=dotColorInput, size=size.tiny)
plotchar(showDotInput and dotSizeInput == "Small" ? price : na, title="Price Dot Small", location=location.absolute, char="•", color=dotColorInput, size=size.small)

Overview

Colour can be fixed or follow rising and falling candles, and style, thickness, length and extension are adjustable. An optional synthetic movement mode splits each move into sub-tick steps so the line glides, and a dot can mark the end. Because it follows the live price, it changes on the open bar.

Details

Published by

shubhamtaywade82 on GitHub

Code credit

nemesis, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

Settings

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

SettingTypeDefaultVariable
Color ModestringCandleslineModeInput
Defaultcolorcolor.silverlineColorDefaultInput
Candles Risingcolor#089981lineColorRisingInput
Candles Fallingcolor#f23645lineColorFallingInput
StylestringDottedlineStyleInput
Thicknessstring1lineThicknessInput
Length (bars)int150lineLengthInput
Extend LeftboolfalselineExtendLeftInput
Extend RightbooltruelineExtendRightInput
Show Secondary LinebooltruesecondLineShowInput
Color ModestringDefaultsecondLineModeInput
Defaultcolorcolor.new(color.silver, 30)secondLineColorDefaultInput
Show all 24 settings
SettingTypeDefaultVariable
Candles Risingcolorcolor.new(#089981, 50)secondLineColorRisingInput
Candles Fallingcolorcolor.new(#f23645, 50)secondLineColorFallingInput
StylestringDashedsecondLineStyleInput
Thicknessstring1secondLineThicknessInput
Length (bars)int0secondLineLengthInput
Extend LeftbooltruesecondLineExtendLeftInput
Extend RightboolfalsesecondLineExtendRightInput
Enable Synthetic MovementbooltrueenableSyntheticInput
Sub-Tick Divisionsint100subTickDivisor
Show DotboolfalseshowDotInput
Dot Colorcolorcolor.blackdotColorInput
Dot SizestringTinydotSizeInput
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

947 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 12 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

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers