我在pinescript中有一个非常简单的策略。
//@version=4
strategy("My Strategy", overlay=true)
longCondition = crossover(sma(close, 14), sma(close, 28))
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
shortCondition = crossunder(sma(close, 14), sma(close, 28))
if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short)
...
我想根据位置大小是否为0绘制一条值为0或1的线。
...
x = strategy.position_size == 0 ? 0 : 1
plot(x)
但是,绘制x的结果是一条仅在值1处的线。
它清楚地表明,在某些时候没有职位空缺。因此
变量position_size
在某些点应该为0,但看起来只有1。
为什么会这样?