止损问题

// ===== 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线检测到了止损点,而实际到了止损点不会自动止损呢

局部代码无法验证

又是ai代码还不全不知道你的ActiveStop是什么类型 在每根k线上怎么变动你可以自己检查下 每根k线的这个值是多少 数据类型是否具有传递性

回复:隔壁大哥更狠他的帖子都是极限测试问题和内容几无关键或全靠热心的兄弟经验去无限思考老王略过老刘抓狂我也怕了

回复:哈哈哈哈哈哈哈哈哈这大哥绰号可能叫“逗你玩儿”

回复:刘老师的头发还能不能经得住折腾哦

回复:这是我下班以后的嘴替

回复:哇 这是给我名分了呀那下班了把脑子留给我😍😍😍