New Function in Pine Script: `line.get_price()`

Jun 23, 2020

We’ve added a new function to Pine Script called line.get_price(). It can be used to determine the price level at which the line is located on a certain bar. This function can also be used to identify the intersection of price and trend lines, as well as to position labels at a precise level along a line. See the new function in use here to position a label on a line:

//@version=4
study("GetPrice", overlay = true)
var line1 = line.new(bar_index[0], high[0], bar_index, low, extend = extend.right)
line.set_xy1(line1, bar_index[25], high[25])
line.set_xy2(line1, bar_index[5], high[5])
var label1 = label.new(bar_index, high, text = "Possible intersection point", 
 style = label.style_label_lower_right, size = size.large)
label.set_xy(label1,bar_index, line.get_price(line1, bar_index))

For more information about this function, check out our Pine Script reference guide.

We hope you’ve enjoyed this update. Please continue to send us your comments and feedback to help us better understand your needs and recommendations for what you’d like to see in the future.

Look first Then leap

TradingView is built for you, so make sure you're getting the most of our awesome features
Launch Chart