所有对象(类型)都是系列的吗?它可以是一个常数吗?

问题描述 投票:0回答:1
//@version=5
indicator("tickerid", overlay = true)

closevalue(tickerid) =>
    sec = request.security(tickerid, '60', close)

type security_type
    string ticker

var security_type mysecurity = security_type.new(syminfo.tickerid)

plot(closevalue(syminfo.tickerid))
plot(closevalue(mysecurity.ticker))

这个非常简单的指标给出了第二个图的以下错误:

无法使用参数“tickerid”=“mysecurity.ticker”调用“#f0”。使用了“系列字符串”类型的参数,但需要“简单字符串”。

即使我将 mysecurity 声明为常量变量,它仍然说它是一个系列?

我怎样才能创建一个常量对象(类型)而不是一个系列?

如果我将 mysecurity 声明为 var 但它没有,我希望它能正常工作。

object types pine-script series pine-script-v5
1个回答
0
投票

在 pinescript 中,无法将系列更改为常量变量。
由于 request.security 必须与常量变量一起使用,因此不能使用标准变量(=系列)。
这是 pinescript 最奇怪的限制之一。

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