[英]<Pinescript> Indicator error using bar prices in arrays
[英]how to debug arrays values in pinescript?
我有这个脚本:
strategy("My strategy")
var float start_price = na
var float end_price = na
var float[] start_prices = array.new_float(0)
var float[] end_prices = array.new_float(0)
var float p = na
f(x) => math.round(x / 500) * 500
lo = (high + close) / 2
var i = 0
if bar_index == 1
start_price := f(lo)
end_price := f(start_price * 1.015)
else
if close <= start_price
strategy.entry(str.format("Long {0}",i), strategy.long)
array.push(end_prices, end_price)
array.push(start_prices, end_price)
i := i + 1
start_price := start_price - 500
end_price := f(start_price * 1.015)
for j = 0 to (array.size(end_prices) == 0 ? na : array.size(end_prices) - 1)
p := array.get(end_prices, j)
if close >= p
strategy.exit(str.format("Long {0}",j), limit=end_price)
我想控制台/调试/显示start_prices
数组中的值但我无法弄清楚如何做到这一点,没有 console.log 或类似的东西。 我是一个有点称职的 python 程序员,但我总是使用print()
......无论如何,人们如何使用这种语言进行调试?
您可以使用tostring()
function ( str.tostring()
在 v5 中)生成数组的字符串。 然后您可以将 output 放入 label 或表中。
例如。
start_prices_string = str.tostring(start_prices)
debug = label.new(x = bar_index, y = close, style = label.style_label_left, text = start_prices_string)
label.delete(debug[1])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.