应该是简单字符串错误:如何使用字符串数组元素调用安全性? [英] pinescript - simple string is expected error: how to call security with a string array element?

查看:6
本文介绍了应该是简单字符串错误:如何使用字符串数组元素调用安全性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过使用数组来存储股票代码值来简化代码。但是,当我使用该数组的元素作为符号论证来调用安全函数时,我得到错误:

Cannot call 'request.security' with argument 'symbol'='ticker'. An argument of 'series string' type was used but a 'simple string' is expected

代码如下

period = timeframe.period
arr = str.split("FB AAPL TSLA MSFT AMZN NFLX GOOG NVDA", " ")
for i = 0 to array.size(arr) -1 
    ticker = array.get(arr, i)
    series = request.security(ticker, period)
    plot(series)

有人知道处理此问题的推荐方法吗?

推荐答案

由于强制转换规则,您无法执行此操作。str.split()返回series string,但您无法将其转换为simple string

必须为每个自动收报机分别调用security()函数。

这篇关于应该是简单字符串错误:如何使用字符串数组元素调用安全性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆