如何在 pine 脚本中使用用户输入值设置 default_qty_value?
how to set up default_qty_value using user input value in pine script?
基本上我想使用用户输入动态更改杠杆头寸的大小,我在 default_qty_value 中有变量 LEVERAGE ,如下所示:
//@version=5
LEVERAGE = input.int(1, minval=1, step=1)
strategy('YTStrategy', overlay=true, margin_long=1, default_qty_type=strategy.percent_of_equity, default_qty_value=LEVERAGE*100, currency=currency.USD, process_orders_on_close=true)
编译器一直报错:
Cannot call 'strategy' with argument 'default_qty_value'='call
'operator *' (input int)'. An argument of 'input int' type was used
but a 'const float' is expected
default_qty_value
的值必须在编译时已知。您不能为此使用用户输入。
您可以将变量更改为常规变量:
LEVERAGE = 1.0
或者使用策略设置来配置这些选项。
基本上我想使用用户输入动态更改杠杆头寸的大小,我在 default_qty_value 中有变量 LEVERAGE ,如下所示:
//@version=5
LEVERAGE = input.int(1, minval=1, step=1)
strategy('YTStrategy', overlay=true, margin_long=1, default_qty_type=strategy.percent_of_equity, default_qty_value=LEVERAGE*100, currency=currency.USD, process_orders_on_close=true)
编译器一直报错:
Cannot call 'strategy' with argument 'default_qty_value'='call 'operator *' (input int)'. An argument of 'input int' type was used but a 'const float' is expected
default_qty_value
的值必须在编译时已知。您不能为此使用用户输入。
您可以将变量更改为常规变量:
LEVERAGE = 1.0
或者使用策略设置来配置这些选项。