不能使用参数"精度"="关闭"调用'math.round'。使用了'series float'类型的参数,但预计会'simple int';松树脚本



我在练习松脚本,我在做一个简单的策略。但是我有这个错误,有人能帮我吗?谢谢!

//@version=5
strategy("Mi semaforo", overlay=true, margin_long=100, margin_short=100)
mm_g = ta.sma(close, 5)
mm_y= ta.sma(close, 10)
mm_r = ta.sma(close, 20)
alcista = (mm_g > mm_y) and (mm_y > mm_r)
// bajista = (mm_g < mm_y) and (mm_y < mm_r)
comprado = strategy.position_size > 0
if (not comprado and alcista) 
cantidad = math.round(strategy.equity, close)
strategy.entry("Compra", strategy.long, cantidad)
if (comprado and not alcista) 
strategy.close("Compra", comment="Venta")

LINE OF ERROR = cantidad = math.round(策略)股本,关闭)

ERROR =第17行:不能调用'math. '四舍五入'与参数'precision'='close'。使用了'series float'类型的参数,但期望是'简单的int';第17行:变量'cantidad'在作用域'#global_#0'中找不到,无法注册副作用

precision参数是四舍五入。

如果使用precision参数,返回一个四舍五入的浮点值小数点后的位数

例如,math.round(3.1234, 2)将返回3.12

如有疑问,请参阅参考手册。

最新更新