根据时间框架使绘图的线宽不同。

huangapple go评论51阅读模式
英文:

Make linewidth of plot to be different according to time frame

问题

我想要制作一张图,当时间框架为1分钟时,线宽为1,其他时间框架为2。

我尝试了以下方法,但没有成功。

//in_1min_tf是一个布尔变量,当图表处于1分钟时间框架时为true
plot(series=test_plot, title='Mid', linewidth=in_1min_tf?1:2, color=color.white)

收到的错误是Cannot call 'plot' with argument 'linewidth'='call 'operator ?:' (simple int)'. An argument of 'simple int' type was used but an 'input int' is expected.

我正在使用pinescript v5。

英文:

I would like to make a plot with linewidth of 1 when timeframe is 1min and linewidth of 2 for other timeframes.

I tried the following but it doesn't work.

//in_1min_tf is a boolean variable which is true when chart is in 1min timeframe
plot(series=test_plot, title='Mid', linewidth=in_1min_tf?1:2, color=color.white) 

The error received is Cannot call 'plot' with argument 'linewidth'='call 'operator ?:' (simple int)'. An argument of 'simple int' type was used but a 'input int' is expected.

I am using pinescript v5.

答案1

得分: 1

linewidth参数中,您必须使用input int,而在series参数中,您可以使用series int/float。根据时间框架,您使用了2个plot函数:

plot(series=in_1min_tf ? test_plot : na, title='Mid', linewidth=1, color=color.white)
plot(series=in_1min_tf ? na : test_plot, title='Mid', linewidth=2, color=color.white)
英文:

While you have to use input int in the linewidth parameter, you can use series int/float to the series parameter. You use 2 plot functions according to the timeframe:

plot(series=in_1min_tf ? test_plot : na, title='Mid', linewidth=1, color=color.white)
plot(series=in_1min_tf ? na : test_plot, title='Mid', linewidth=2, color=color.white)

huangapple
  • 本文由 发表于 2023年2月24日 11:20:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75552327.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定