尝试创建一个简短的策略,但出现“无数据”错误。
enterIndex = 0.0
enterIndex := enterIndex[1]
inPosition = not na(strategy.position_size) and strategy.position_size<0
if inPosition and na(enterIndex)
enterIndex := bar_index
if (shortCondition)
strategy.entry("SHORT", strategy.short)
if (not na(enterIndex) and bar_index - enterIndex + 1 >= 3 )
strategy.close( "CLOSE")
答案 0 :(得分:0)
您必须关闭您开立的头寸。
ID 必须匹配。 就您而言,如果您开仓 SHORT ,您也必须将其平仓。
if (shortCondition) strategy.entry("SHORT", strategy.short)
if (不是 na(enterIndex) 和 bar_index - enterIndex + 1 >= 3 )
strategy.close( "SHORT")