我写的止损程序代码在回测的时候不触发什么原因,请老师给指点一下

If(CurrentPosition != 0)

   {

       Numeric stopPrice;

       Bool needStop(False);

       Numeric triggerPrice;

       

     

       

       If(CurrentPosition == 1) // 多单止损检查

       {

           // 精确止损价计算(含4位小数)

           stopPrice = Round(AvgLongPrice * (1 - 0.006),4);

         

           

           // 改进触发逻辑:考虑盘中价格波动

           If(Low <= stopPrice)

           {

               needStop = True;

               // 确定实际触发价(考虑跳空情况)

               triggerPrice = IIF(Open < stopPrice, Open, Min(Close, stopPrice));

               triggerPrice = Min(Low, triggerPrice);

           }

       }

请教 有时候触发有时候不触发是什么原因?
求老师帮忙指点一下
设置 触发OnBarOpen的时间函数怎么写,请老师给写一个
求老师指点一下,NumericRef 在设置参数的时候,为什么显示无法识别的字符串
请老师帮忙讲解一下这样写的好处
跨周期策略在回测时遇到的问题
批量回测的时候,参数优化
止损代码请教
我用chatgtp 编译成功了一个策略,有老师高手请求指点,谢谢!
遍历期权图层时,偶然发生不执行的交易代码的情况,请TB老师分析

CurrentPosition 你检查过吗?

你代码贴的内容里,一个CurrentPosition 的赋值都没有

CurrentPosition ==1 既然你判断这个,那么CurrentPosition 里有过是1吗

   

       If(needStop)

       {

           // 优先执行止损

           If(CurrentPosition == 1)

           {

               Sell(TotalLongLots, triggerPrice);

               CurrentPosition = 0;

               TotalLongLots = 0;

               AvgLongPrice = 0;

             

           }