如何区分一个表达式?
How to differentiate an expression?
这是基本布林带宽度指标的脚本(加上我评论的解释):
//@version=5
indicator(title="Bollinger Bands Width", shorttitle="BBW", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
length = input.int(20, minval=1)
src = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
bbw = (upper-lower)/basis
// Explanation of what I seek:
// bbwd = bbw minus previousbbw
plot(bbwd, "Bollinger Bands Width Differenctial", color=#138484)
有一个注释行以“我需要的示例”开头。我想通过从 Width 的当前值中减去 Width 的先前值来创建一个变量。测量速度。
这显示了实现目标的两种不同方式。精度提高到 6,因为值很小:
//@version=5
indicator(title="Bollinger Bands Width", shorttitle="BBW", format=format.price, precision=6, timeframe="", timeframe_gaps=true)
length = input.int(20, minval=1)
src = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
bbw = (upper-lower)/basis
// Explanation of what I seek:
// bbwd = bbw minus previousbbw
bbwd1 = ta.change(bbw)
bbwd2 = bbw - bbw[1]
plot(bbwd1, "Bollinger Bands Width Differenctial", color=#13848450, linewidth=6)
plot(bbwd2, "Bollinger Bands Width Differenctial", color=#138484)
这是 ta.change()
. This is the usrman section that explains the []
history-referencing operator 的 refman 条目。
这是基本布林带宽度指标的脚本(加上我评论的解释):
//@version=5
indicator(title="Bollinger Bands Width", shorttitle="BBW", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
length = input.int(20, minval=1)
src = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
bbw = (upper-lower)/basis
// Explanation of what I seek:
// bbwd = bbw minus previousbbw
plot(bbwd, "Bollinger Bands Width Differenctial", color=#138484)
有一个注释行以“我需要的示例”开头。我想通过从 Width 的当前值中减去 Width 的先前值来创建一个变量。测量速度。
这显示了实现目标的两种不同方式。精度提高到 6,因为值很小:
//@version=5
indicator(title="Bollinger Bands Width", shorttitle="BBW", format=format.price, precision=6, timeframe="", timeframe_gaps=true)
length = input.int(20, minval=1)
src = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
bbw = (upper-lower)/basis
// Explanation of what I seek:
// bbwd = bbw minus previousbbw
bbwd1 = ta.change(bbw)
bbwd2 = bbw - bbw[1]
plot(bbwd1, "Bollinger Bands Width Differenctial", color=#13848450, linewidth=6)
plot(bbwd2, "Bollinger Bands Width Differenctial", color=#138484)
这是 ta.change()
. This is the usrman section that explains the []
history-referencing operator 的 refman 条目。