如何在“设置”下将变量和文本连接到 input( ) 请求?

问题描述 投票:0回答:1

我对编程还很陌生,我正在尝试为 PineScript 中的交易视图创建一组非常简单的级别。我已经成功绘制了这些级别,现在我想在绘制的级别上方添加文本。我想在“设置输入”中的这些级别旁边添加文本。我可以轻松创建标准输入(“”、“4808 标签”),但我希望 4808 自动显示在“设置”中的单词标签之前,因为这些级别每天都会变化。

support_color = input.color(color.rgb(255, 128, 255), "Support Color", inline="Support")
offset = input.int(defval = 50, title = "Offset Labels")
hline_smajor_1 = 4808.0
hline(hline_smajor_1, "(major)", color=support_color, linestyle=hline.style_solid, linewidth=3)

**// this next line is where I get the following errors. I understand I'm trying to concatenate a variable and text but don't know how to work around these errors**
// Error at 65:64 Cannot call 'operator +' with argument 'expr0'=' Label'. An argument of 'literal string' type was used but a 'simple int' is expected.
// Error at 65:32 Cannot call 'input' with argument 'title'='call 'str.tostring' (simple string)'. An argument of 'simple string' type was used but a 'const string' is expected.

**hline_smaj_text_1 = input(" ", str.tostring(hline_smajor_1), + " Label")**

label hline_smaj_label_1 = label.new(bar_index + offset, hline_smajor_1, hline_smaj_text_1, style=label.style_none, textcolor=color.white)

label.delete(hline_smaj_label_1[1])

// Dummy plot to hide price scale
plot(0, display=display.none)

如果这些值在第二天仍然存在,比如“hline_smajor_1”更改为“4810.0”,我认为代码将恢复为“”默认输入。如果情况并非如此,我希望删除前几天的注释,因为我将使用相同的变量“hline_smajor_1”、“hline_smajor_2”等

我确信有一个简单的解决方法,但我被困住了,经过一个多小时的搜索后,我无法在网上找到任何东西。

hline_smaj_text_1 = input(" ", str.tostring(hline_smajor_1), + " Label")

在“设置”下我期待:

4808 标签和默认值为空,4808 将从我的变量中自动填充

input view concatenation pine-script pine-script-v5
1个回答
0
投票

在“设置”中,无法使用动态值。只允许使用常量值。

© www.soinside.com 2019 - 2024. All rights reserved.