Pine scripts are now interactive

Oct 20, 2021

A new interactive input mode for price and time inputs is now available. Instead of selecting price and time from input widgets, you can now select them by clicking on the chart. The interactive mode is activated by using confirm = true in input.time() and input.price().

This is code for an Anchored VWAP indicator where the anchor point is set interactively, just as with the drawing tool of the same name: 

indicator("Anchored VWAP", overlay=true)
src = input.source(hlc3, "Source")
startCalculationDate = input.time(timestamp("20 Jan 2021"), "Start Calculation", confirm=true)
vwap_calc() =>
    var srcVolArray = array.new_float(na)
    var volArray = array.new_float(na)
    if startCalculationDate <= time
        array.push(srcVolArray, src*volume)
        array.push(volArray, volume)
        array.clear(srcVolArray), array.clear(volArray)
anchoredVwap = vwap_calc()
plot(anchoredVwap, "VWAP", linewidth=3)

When it is necessary to select both a price and time simultaneously, use an inline parameter with the same value in both function calls:

indicator("Point", overlay=true)
myPrice = input.price(100, inline="Point", confirm=true)
myTime = input.time(timestamp("2020-02-20"), inline="Point", confirm=true)
lblText = str.format("Price: {0, number}\nTime: {1, date} {1, time}", myPrice, myTime)
var l1 =, myPrice, lblText, xloc=xloc.bar_time)

Reminders appear on the chart to guide users when they are in interactive input mode: 

After adding an indicator and making an initial interactive selection on the chart, you can modify the selection points by selecting the indicator and moving the points on the chart.

You can see the new feature in action in these publications:

CAGR by TradingView

AutoTrail by Bjorgum

To stay informed of new Pine features, keep an eye on our Pine User Manual’s Release notes. The PineCoders account also broadcasts updates from its Squawk Box Telegram channel, Twitter account, and from the Pine Script public chat on TradingView.

We hope you find this highly-requested feature useful. Please keep giving us your feedback and suggestions for improvement — we build TradingView for you, and we’re always keen to hear from you.

Look first Then leap

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