Pine script 策略。退出未正确触发

Pine script 策略。退出未正确触发,pine-script,algorithmic-trading,trading,Pine Script,Algorithmic Trading,Trading,我有一个退出策略: if (inDateRange) strategy.entry("long ema", true, Buy_Quantity, when = Buy_Signal == 1 and valuewhen(Buy_Signal == 1, close, 0) < R3_pp, comment = tostring((LongProfitPrice * 0.05))) strategy.entry("short ema"

我有一个退出策略:

if (inDateRange)
    strategy.entry("long ema", true, Buy_Quantity, when = Buy_Signal == 1 and valuewhen(Buy_Signal == 1, close, 0) < R3_pp, comment = tostring((LongProfitPrice * 0.05)))
    strategy.entry("short ema", false, Sell_Quantity, when = Sell_Signal == 1 and valuewhen(Sell_Signal == 1, close, 0) > S3_pp, comment = tostring(ShortProfitPrice * 0.05))



if (strategy.opentrades == 1)
    if (inDateRange)
        strategy.exit("exit", "long ema", profit = LongProfitPrice, loss = LongLossPrice , comment = tostring(LongLossPrice * 0.05))
        strategy.exit("exit", "short ema", profit = ShortProfitPrice, loss = ShortLossPrice , comment = tostring(ShortLossPrice * 0.05))
if(inDateRange)
策略.输入(“多头均线”,真,买入数量,何时=买入信号==1,何时(买入信号==1,收盘,0)S3,注释=tostring(空头利润价格*0.05))
如果(strategy.opentrades==1)
if(inDateRange)
策略.退出(“退出”,“长期均线”,利润=长期利润价格,损失=长期利润价格,注释=tostring(长期利润价格*0.05))
策略.退出(“退出”,“空头均线”,利润=空头利润价格,损失=空头损失价格,注释=tostring(空头损失价格*0.05))
短出口第一次运行良好,但第二次不起作用

进入卖空信号有盈利金额,退出卖空信号有亏损金额

在第一次交易中,它正确地记录了利润,但在第二次交易中,它退出了错误的交易

策略说它是作为止损退出的,那么为什么214.90它应该在损失为82.58时退出呢

另一个例子:(3和4可以比较)