我试图在过去的第 2 根蜡烛收盘时设置止损。我制作的情节是准确的,但策略退出不是。有人可以帮我吗?
strategy("Test Strategy", overlay=true, pyramiding=0)
sma_short = sma(close, 21)
sma_medium = sma(close, 50)
sma_long = sma(close, 200)
is_up_trend = close[0] > close[1] and close > sma_short and sma_short > sma_medium and sma_medium > sma_long //and sma_short[0] > sma_short[1] and sma_medium[0] > sma_medium[1] and sma_long[0] > sma_long[1]
loss = close[0] - low[2]
plot(close[0] - loss, color=color.red, style=plot.style_stepline)
if crossover(sma_short, sma_medium) and is_up_trend
strategy.entry('long', strategy.long)
strategy.exit("long", loss=loss / syminfo.mintick)