简体   繁体   English

松脚本中的“tostring”function

[英]'tostring' function in pine-script

I'm trying to create plot name based on input value.我正在尝试根据输入值创建 plot 名称。 However getting error (in line#6).但是出现错误(在第 6 行)。 Below is my code.下面是我的代码。 Thank you so much for your time and reply.非常感谢您的宝贵时间和回复。

//@version=4
study(title="EMA", shorttitle="ema", overlay=true)
ema_len = input(50, title='Period')
EMA = ema(close, ema_len)
plot_name = 'EMA' + tostring(ema_len)
plot(EMA, title=plot_name)

Error message:错误信息:

Add to Chart operation failed, reason: line 6: Cannot call 'plot' with 'title'=string. The argument should be of type: const string

Const strong means we can't dynamically change a title. Const strong 意味着我们不能动态更改标题。 The settings menu isn't setup to change with user input infront if your eyes.如果您的眼睛在眼前,设置菜单不会随着用户输入而改变。 So we just have to choose a name for our plot.所以我们只需要为我们的情节选择一个名字。

Cheers.干杯。

delete line 5 and just do删除第 5 行,然后执行

plot(EMA, title='EMA')

in line 6在第 6 行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM