之后传递的一系列数据如何评估?:
How is evaluated a series of data when passed after ?:
我是 pinescript 的新手,我试图了解它是如何工作的,我正在努力完全理解 iff 语句 (?:) 以及它在传递之后如何评估一系列数据?:
例如。
higher_than = high > close
x = higher_than ? 1 : 0
b = x > 0 ? higher[2]: na
x 被评估为每个在 higher_than 中为真的值被替换为 1,如果值为假则被替换为 0。
但是 b 语句呢?
这个有用吗?
对于 x 中大于零的每个值,用同一索引处的更高值替换它?
这向您展示了如何调试脚本,以便您可以检查每个柱的所有计算值。使用数据 Window 进行调试非常有用。通过检查其中的值,您应该能够回答自己的问题。做不到就直说
//@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)
我是 pinescript 的新手,我试图了解它是如何工作的,我正在努力完全理解 iff 语句 (?:) 以及它在传递之后如何评估一系列数据?: 例如。
higher_than = high > close
x = higher_than ? 1 : 0
b = x > 0 ? higher[2]: na
x 被评估为每个在 higher_than 中为真的值被替换为 1,如果值为假则被替换为 0。 但是 b 语句呢? 这个有用吗?
对于 x 中大于零的每个值,用同一索引处的更高值替换它?
这向您展示了如何调试脚本,以便您可以检查每个柱的所有计算值。使用数据 Window 进行调试非常有用。通过检查其中的值,您应该能够回答自己的问题。做不到就直说
//@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)