如何执行有条件的推送到数组(在 Pine Script 上)?
How does one execute a CONDITIONAL push-to-array (on Pine Script)?
我正在尝试在满足特定条件时将数据条目以队列格式推送到数组中。
为简单起见,每当 volume == volume[1] 时,用价格值填充一个 [大小为 20] 的数组,我尝试了以下操作:
//@version=4
study(title="ConditionalArrayPush", overlay = false)
var dataset = array.new_float(20)
array.shift(dataset) //storing datapoints FIFO
if (volume == volume[1])
array.push(dataset, close)
sampleoutput = array.min(dataset)
plot(sampleoutput, "Test", color.white)
脚本不会 运行。
帮助。
Pine 将 na
值的数组视为空数组。如果您在删除最旧的值之前先添加一个新值,那么在条件为真且数组为所有 na
值的第一个柱上,您将不会 运行 通过这样做来解决这个问题订单。
另外,您的 volume == volume[1]
条件很可能永远不会发生,因此很可能什么都不会添加到数组中。
//@version=4
study(title="ConditionalArrayPush", overlay = false)
var dataset = array.new_float(20)
if volume >= volume[1]
array.push(dataset, close)
array.shift(dataset)
sampleoutput = array.min(dataset)
plot(sampleoutput, "Test", color.white)
我正在尝试在满足特定条件时将数据条目以队列格式推送到数组中。
为简单起见,每当 volume == volume[1] 时,用价格值填充一个 [大小为 20] 的数组,我尝试了以下操作:
//@version=4
study(title="ConditionalArrayPush", overlay = false)
var dataset = array.new_float(20)
array.shift(dataset) //storing datapoints FIFO
if (volume == volume[1])
array.push(dataset, close)
sampleoutput = array.min(dataset)
plot(sampleoutput, "Test", color.white)
脚本不会 运行。 帮助。
Pine 将 na
值的数组视为空数组。如果您在删除最旧的值之前先添加一个新值,那么在条件为真且数组为所有 na
值的第一个柱上,您将不会 运行 通过这样做来解决这个问题订单。
另外,您的 volume == volume[1]
条件很可能永远不会发生,因此很可能什么都不会添加到数组中。
//@version=4
study(title="ConditionalArrayPush", overlay = false)
var dataset = array.new_float(20)
if volume >= volume[1]
array.push(dataset, close)
array.shift(dataset)
sampleoutput = array.min(dataset)
plot(sampleoutput, "Test", color.white)