英文:
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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论