首页 > 解决方案 > 从自定义输入设置策略佣金类型

问题描述

我想从我的脚本的输入中设置佣金类型(即使仍然可以在属性选项卡上更改它)。使用我当前的代码,我收到此错误:

无法使用“commission_type”=字符串调用“策略”。参数的类型应该是:const string

我尝试了不同的方法,但如果我想根据输入选项分配值,我会不断收到相同的错误。

input_commission_type =input(title = "", defval = '%', options=['%', 'per contract', 'per order'])

txt_input_commission_type := if input_commission_type == "%"
     strategy.commission.percent
else if input_commission_type == "per contract"
     strategy.commission.cash_per_contract
else if input_commission_type == "per order"
     strategy.commission.cash_per_order

strategy(commission_type=txt_input_commission_type, ......

标签: pine-script

解决方案


推荐阅读