如何正确减少来自 Pine Script 的安全调用? [英] How to correctly reduce security calls from Pine Script?

查看:29
本文介绍了如何正确减少来自 Pine Script 的安全调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个仪表板,为多个符号计算相同的条件

我目前正在调用这样的安全功能,因此我可以将它用于多个符号.但是,如您所见,这需要 4 次安全调用.

getCandle(symbol) =>_open = security(符号,240",打开)_close = security(符号,240",关闭)_high = 安全性(符号,240",高)_low = 安全性(符号,240",低)[_open, _close, _high, _low]

然后我的脚本为不同的符号重复调用此函数,如下所示

[_open, _close, _high, _low] = getCandle(OANDA:USDJPY")//用蜡烛做点什么

我有 20 多个符号,所以我很快就遇到了最大安全调用/脚本错误.

为了优化这一点,我按照文档中所示进行了尝试

getCandle(symbol) =>[_open, _close, _high, _low] = security(symbol, "240", [open, close, high, low])

在我进行此更改的那一刻,我在控制台上收到了大量错误,内容类似于

line 85: 不能用参数调用'anonym_function_10' (fun_arg__<anonym_function_7_arg0_type>, fun_arg__<anonym_function_7_arg1_type>, fun_arg__<anonym_function_7_arg2_type>integer_input> integer_type>输入第 85 行:无法使用参数调用anonym_function_11"(fun_arg__

I am trying to make a dashboard which calculates same condition for multiple symbols

I am currently calling security function like this, so I can use it for multiple symbols. However, as you can see it takes 4 security calls.

getCandle(symbol) =>
    _open = security(symbol, "240", open)    
    _close = security(symbol, "240", close)
    _high = security(symbol, "240", high)
    _low = security(symbol, "240", low)
    [_open, _close, _high, _low]

This function is then repeatedly called for different symbols by my script as follows

[_open, _close, _high, _low] = getCandle("OANDA:USDJPY")
// do something with the candle

I have 20+ symbols, so I quickly ran into max security calls/script error.

To optimize this, I tried as shown in the docs

getCandle(symbol) =>
    [_open, _close, _high, _low] = security(symbol, "240", [open, close, high, low])

The moment I make this change, I get huge number of errors on the console which read something like

line 85: Cannot call 'anonym_function_10' with arguments (fun_arg__<anonym_function_7_arg0_type>, fun_arg__<anonym_function_7_arg1_type>, fun_arg__<anonym_function_7_arg2_type>, fun_arg__<anonym_function_7_arg3_type>, input integer, input integer);
line 85: Cannot call 'anonym_function_11' with arguments (fun_arg__<anonym_function_7_arg0_type>, fun_arg__<anonym_function_7_arg1_type>, fun_arg__<anonym_function_7_arg2_type>, fun_arg__<anonym_function_7_arg3_type>, input integer, input integer);
line 85: Undeclared identifier '#var_24';

Can someone please help to understand what is incorrect in the optimized code?

Thanks a bunch!

解决方案

hm, works for me: (you don't even need the getCandle function anymore at this point)

// © marketscripters

//@version=4
study("My Script")

[_open, _close, _high, _low] = security("GBPUSD", "240", [open, close, high, low])
[_o2, _c2, _h2, _l2] = security("EURUSD", "240", [open, close, high, low])

plot(_low)
plot(_high)
plot(_l2, color=color.green)
plot(_h2, color=color.green)

这篇关于如何正确减少来自 Pine Script 的安全调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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