Pine script 在之后传递时,如何评估一系列数据

Pine script 在之后传递时,如何评估一系列数据,pine-script,Pine Script,我是pinescript的新手,我试图理解事情是如何工作的,我正在努力完全理解iff语句(?:),以及它在传递之后是如何计算一系列数据的 比如说 higher_than = high > close x = higher_than ? 1 : 0 b = x > 0 ? higher[2]: na 对于每一个在高于1的_中为真的值,x将被计算,如果一个值为假,它将被替换为0。 但是b语句呢? 这有用吗 对于x中高于零的每个值,请在同一索引中将其替换为更高的值?这说明了如何调试脚本,

我是pinescript的新手,我试图理解事情是如何工作的,我正在努力完全理解iff语句(?:),以及它在传递之后是如何计算一系列数据的 比如说

higher_than = high > close
x = higher_than ? 1 : 0
b = x > 0 ? higher[2]: na
对于每一个在高于1的_中为真的值,x将被计算,如果一个值为假,它将被替换为0。 但是b语句呢? 这有用吗


对于x中高于零的每个值,请在同一索引中将其替换为更高的值?

这说明了如何调试脚本,以便可以检查每个条的所有Calc值。使用数据窗口进行调试非常有用。通过检查其中的值,您应该能够回答自己的问题。如果你不能,就这么说吧

//@version=4
study("Debugging", "", true)
higher_than = high > close
x = higher_than ? 1 : 0
b = x > 0 ? high[2]: na
// This is a boolean so we plot a dot when it's true.
plotchar(higher_than, "higher_than", "•", location.top)
// This is a 0/1 value so we can't plot it on the chart because it will ruin the scale, so we plot it in the Data Window.
plotchar(x, "x", "", location.top)
// This value fits in the chart's price scale, so we can plot it directly on the chart. This plots the high from 2 bars ago.
plot(high[2], "high[2]")
// This also fits on the chart, but we use a different color and make the plot wider 
// and more transparent so the previous plot in the default blue can show through.
plot(b, "b", color.orange, 5, transp = 60)