April 26, 2017
Several new features added to the Pine scripting language

A new “barstate.isconfirmed” variable has been added to the list of variables that return bar status (barstate.isrealtime, barstate.ishistory, barstate.islast etc.). It lets you create indicators that are calculated based on the closed (or updatable) bars only. “Barstate.isconfirmed” value is false when the bar is being updated in real-time except for the last update for the bar.

study("Price prediction, barstate.isconfirmed sample")
prediction = not barstate.isconfirmed ? 2 * close - close[1] : na
plot(prediction, style=cross, linewidth=3, offset=1)


We’ve added an “options” argument for the “input” function. You’ve probably noticed that some built-in indicators have a setting that lets you choose several options. You can do the same in Pine Script now.

study(title="Average True Range, input with options sample", shorttitle="ATR", overlay=false)
length = input(14, minval=1)
smoothing = input(defval="RMA", options=["RMA", "SMA", "EMA", "WMA"])

ma(smoothing, src, length) => 
    if smoothing == "RMA"
        rma(src, length)
        if smoothing == "SMA"
            sma(src, length)
            if smoothing == "EMA"
                ema(src, length)
                if smoothing == "WMA"
                    wma(src, length)

plot(ma(smoothing, tr(true), length), color=red)


Upcoming updates will significantly expand the possibility of using variables in functions (including the input function). The following call will be available among other features.

opt1 = "option1", opt2 = "option2"
i = input(opt1, options=[opt1, opt2])
if i == opt1

The fastest way to follow markets

Launch Chart