止损问题
// ===== 4.3 时间止损 ===== if (!OrderSentThisBar && BarsHeld >= TimeStopBars && CurrentProfitLevel == 0 && CurrentPosition > 0) { Numeric CloseQty = Max(1, IntPart(CurrentPosition * 0.5)); if (MarketPosition == 1 && Close <= EntryPrice) { Sell(CloseQty, Open); OrderSentThisBar = True; Commentary("时间止损: 平仓50%"); } else if (MarketPosition == -1 && Close >= EntryPrice) { BuyToCover(CloseQty, Open); OrderSentThisBar = True; Commentary("时间止损: 平仓50%"); } } } // ===== 5. 即时止损检查 ===== if (MarketPosition != 0 && !OrderSentThisBar && CurrentPosition > 0) { // 多头止损检查 if (MarketPosition == 1) { // 使用更精确的盘中止损检查 if (Low <= ActiveStop) { // 计算精确止损价格 Numeric StopPrice = Max(Low, ActiveStop); StopPrice = IntPart(StopPrice / MinPoint) * MinPoint; // 确保止损价有效 if (StopPrice > 0) { Sell(CurrentPosition, StopPrice); OrderSentThisBar = True; StopLossTriggered = True; Commentary("【止损触发】价格: " + Text(StopPrice) + " | 初始: " + Text(InitialStop) + " | 当前: " + Text(ActiveStop)); } } } // 空头止损检查 else if (MarketPosition == -1) { if (High >= ActiveStop) { Numeric StopPrice = Min(High, ActiveStop); StopPrice = IntPart(StopPrice / MinPoint) * MinPoint; if (StopPrice > 0) { BuyToCover(CurrentPosition, StopPrice); OrderSentThisBar = True; StopLossTriggered = True; Commentary("【止损触发】价格: " + Text(StopPrice) + " | 初始: " + Text(InitialStop) + " | 当前: " + Text(ActiveStop)); } } } // 止损检查日志 if (!StopLossTriggered) { Commentary("止损监控: " + "当前止损=" + Text(ActiveStop) + " | 最低价=" + Text(Low) + " | 最高价=" + Text(High)); } } // ===== 6. 状态报告 ===== Commentary("状态: " + "持仓=" + Text(MarketPosition) + " | 天数=" + Text(BarsHeld) + " | 止损=" + Text(ActiveStop) + " | 阶段=" + Text(CurrentProfitLevel) + " | 已发单=" + Text(IIf(OrderSentThisBar, 1, 0))); PlotNumeric("止损线", ActiveStop); }为什么前跟k线检测到了止损点,而实际到了止损点不会自动止损呢