Percentage Tracking Line TradingView Chart

Draw hline at TradingView chart at :

  • 1% increase of current price
  • 1% decrese of current price

Screenshot

  1. Go to TradingView
  2. open Pine Editor
  3. copy paste script from below
//@version=4
study("Percentage Tracking", overlay=true)

_lastTradedPrice = close // define price

// LINE 1
line1active = input(title="Line 1 Active", type=input.bool, defval=true)
line1percentage = input(title="Line 2 Percentage", type=input.float, defval=1.01, minval=-1000, maxval=1000, step=0.01)
line1color = input(title="Color", type=input.color, defval=color.green)

if(line1active)
    var line _lpLine = line.new(0, 0, 0, 0, extend=extend.both, style=line.style_dashed, color=line1color, width=1)
    line.set_xy1(_lpLine, bar_index-1, _lastTradedPrice * line1percentage)
    line.set_xy2(_lpLine, bar_index, _lastTradedPrice * line1percentage)

// LINE 2
line2active = input(title="Line 2 Active", type=input.bool, defval=true)
line2percentage = input(title="Line 2 Percentage", type=input.float, defval=0.99, minval=-1000, maxval=1000, step=0.01)
line2color = input(title="Color", type=input.color, defval=color.orange)
if(line2active)
    var line _bottomLine = line.new(0, 0, 0, 0, extend=extend.both, style=line.style_dashed, color=line2color, width=1)
    line.set_xy1(_bottomLine, bar_index-1, _lastTradedPrice * line2percentage)
    line.set_xy2(_bottomLine, bar_index, _lastTradedPrice * line2percentage)

;