第一个线满足条件 也执行了代码 但是每次 都返回失败

商品128081,加载策略后,每次 都可以执行buy 语句,但是buy的返回值都是失败,第二个k线成功。

换了很多品种 都是这样?

为什么?

Params
    Numeric up(120);
    Numeric gridsize(0.5);

Vars
    Series<Numeric> last_price;    
    Series<Numeric> counter(0);    
    

    

Events
    //此处实现事件函数
    
    //初始化事件函数,策略运行期间,首先运行且只有一次,应用在订阅数据等操作
    

    //Bar更新事件函数,参数indexs表示变化的数据源图层ID数组
    OnBar(ArrayRef<Integer> indexs)
    {
        Commentary(text(last_price));
        Commentary(text(counter));
        Commentary("last_price[1]=" + text(last_price[1]));
        Commentary("counter[1]=" + text(counter[1]));
        Commentary("low=" + text(low));
        Commentary("MarketPosition=" + text(MarketPosition));

        
        if (low < up and counter == 0 )
        {
            Commentary("下单");
            bool b = buy(100, low);
            if (b)
                Commentary("ok");
            Else
                Commentary("no");
            PlotAuto("con",b,high); 
            if (b)
                {
                    last_price = low;
                    counter = counter + 1;
                }

        }
        

        
        
        
        
        
    }
 

第一个发单满足的时候有发单,但是图表上未记录信号
5分K线,如何实现跳到下一根K线之前 后5秒 就不下单了 或满足条件也不用显示交易信号了
ATR到底怎么用?每次都又问题?!
求连续满足某条件
交易套利合约,满足平仓条件策略没有平仓且信号消失
如何写:在X根K线内触发过条件A后,满足条件B开仓
满足条件的周期统计问题
多图层条件满足先后问题
buy/sell下单返回ture,但实际下单失败
不是所有控件路径都返回值

这个我运行稍微看了一下,你的代码就是无论任何条件立马开仓,然后没有平仓,也不在加仓。

照这个逻辑,开仓信号应该出在第一根bar上,后面不会再出现任何信号。不太清楚是哪里觉得不对?