我们最新的Pine更新对输入进行了两项改进:
- 新的group参数允许程序员为一组输入定义节标头。
- 新的inline参数允许将多个输入连接在一行上。
使用这些新功能,您可以更整齐地组织输入,就像我们在这里为自动斐波那契回撤(Auto Fib Retracement)指标所做的那样。

在脚本中使用新参数很容易! 看一下这个VWAP指标的示例,该指标允许用户指定计算的起点和终点,并控制锚点的显示:
//@version=4
study(title = "Custom Period VWAP", shorttitle = "CPVWAP", overlay = true)
src = input(hlc3, "Source", input.source)
enableHighlight = input(true, "Highlight", input.bool, inline = "Highlight")
highlightType = input("Anchors", "", input.string, options = ["Anchors", "Background"], inline = "Highlight")
highlightColor = input(color.red, "", input.color, inline = "Highlight")
useStartPeriodTime = input(true, "Start", input.bool, group = "Date Range", inline = "Start Period")
startPeriodTime = input(timestamp("20 Jan 2021"), "", input.time, group = "Date Range", inline = "Start Period")
useEndPeriodTime = input(true, "End", input.bool, group = "Date Range", inline = "End Period")
endPeriodTime = input(timestamp("20 Feb 2021"), "", input.time, group = "Date Range", inline = "End Period")
start = useStartPeriodTime ? startPeriodTime >= time : false
end = useEndPeriodTime ? endPeriodTime <= time : false
calcPeriod = not start and not end
var srcVolArray = array.new_float(na)
var volArray = array.new_float(na)
var line startAnchor = line.new(na, na, na, na, xloc.bar_time, extend.both, highlightColor, width = 2)
var line endAnchor = line.new(na, na, na, na, xloc.bar_time, extend.both, highlightColor, width = 2)
useBgcolor = false
if calcPeriod
array.push(srcVolArray, src*volume)
array.push(volArray, volume)
else
array.clear(srcVolArray), array.clear(volArray)
customVwap = array.sum(srcVolArray) / array.sum(volArray)
if enableHighlight
if highlightType == "Anchors"
if useStartPeriodTime
line.set_xy1(startAnchor, startPeriodTime, low)
line.set_xy2(startAnchor, startPeriodTime, high)
if useEndPeriodTime
line.set_xy1(endAnchor, not na(customVwap) ? time : line.get_x1(endAnchor), low)
line.set_xy2(endAnchor, not na(customVwap) ? time : line.get_x1(endAnchor), high)
if highlightType == "Background"
useBgcolor := true
bgcolor(useBgcolor and calcPeriod ? highlightColor : na, editable = false)
plot(customVwap, title="CPVWAP", color = color.blue, linewidth = 2)

group参数有两种使用方式。该字符串用作该组的标头,并且还定义了哪些输入属于该组。
当使用inline参数时,使用相同inline参数的所有input()调用将加入到一行上。每个input()调用的title参数确定该字段的图例。如果在input()调用中未使用title参数,则该字段将不使用图例。如果使用inline组合的输入不适合一行,则其中一些输入将换行到下一行。
您可以在《Pine语言参考手册》的input()条目中找到有关新参数的描述。
在我们的《Pine用户手册》发行说明中阅读有关Pine的所有更新。
我们希望您发现这项高需求度的功能有用。请继续向我们发送您的反馈意见以帮助改进。我们为用户创建了TradingView,希望收到您的来信。
还没有关注我们的中文微信公众号?快来扫二维码吧!