繁体   English   中英

tradingview pinescript 不能在安全性 function 中使用可变变量作为参数

[英]tradingview pinescript cannot use mutable variable in security function as an argument

在写这篇文章之前,我尝试了这里给出的某些想法仍然不起作用,所以再次询问。

这是 V4 代码 V2 =True SarUp 整数值 emaslow integer 值 //code from here

get_pltval(V2,sarUp,emaSlow) =>
    pltval = 0.0
    plval := V2 ? sarUp <= ohlc4 and sarUp[2] > high and sarUp[3] > high and sarUp[4] > high ? 1 : 0 : ohlc4 > emaSlow ? 1 : 0

var _src = 0.0 
_src := get_pltval(V2,sarUp,emaSlow)

test = security(syminfo.tickerid, tf, _src, barmerge.gaps_off, barmerge.lookahead_off)

错误不能在安全 function 中使用可变变量作为参数

这个问题的任何解决方案。请分享

默认情况下, barmergelookahead是“关闭”的,因此无需显式定义它们。 您可以从security()调用 function :

//@version=4
study("")
get_pltval(V2,sarUp,emaSlow) =>
    pltval = 0.0
    plval := V2 ? sarUp <= ohlc4 and sarUp[2] > high and sarUp[3] > high and sarUp[4] > high ? 1 : 0 : ohlc4 > emaSlow ? 1 : 0

test = security(syminfo.tickerid, tf, get_pltval(V2,sarUp,emaSlow))

暂无
暂无

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

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