为什么买开仓,卖平今价格是跌停价
2022-08-01 15:09

 

Vars
    Tick mytick;
    Global Integer timerID;
    Global Numeric BuyorSell;
    Global Integer  ordL1;
    Array<Integer> orderId;
Events    
    OnInit()
    {
        SubscribeBar( "l2209.DCE","TICK",SystemDateTime);//SystemDateTime
        timerID = CreateTimer(5000,0);
    }
    OnTimer(Integer id,Integer millsecs)
    {
        If(id==timerID)
        {
            
             BuyorSell = IntPart( Rand(1,3));//取随机整数
             PlotAuto("bos",BuyOrSell);
            }
            If(BuyOrSell==1)
            {
                A_SendOrderEx(Enum_sell,Enum_Entry,1,mytick.bidask1.askP,orderId);
                 ordL1=orderId[0];
                print("1: 1");
            }
    }
    OnOrder(OrderRef ord)
    {            
      If(ord.status==Enum_Filled)//全部成交
        {
            If(ord.orderId==ordL1)
            {
                A_SendOrderEx(Enum_buy,Enum_ExitToday,1,ord.price-2,orderId);
                 
                 Print("2= 2");
            }
        }
    }
    OnBar(ArrayRef<Integer> indexs)
    {
        GetTick(mytick);
        //Print("买1= "+Text(mytick.bidask1.bidp));
        //Print("mai1= "+Text(mytick.bidask1.askp));
    }

print卖一买一到控制台价格没错,程序运行时无论买开、平空价格委托价格变成跌停价,多单开不了,空单平不了

只能手动撤单再平仓

各位大佬看看问题出在哪里?

谢谢!

 

评论区
hn0512

yes

2022-08-01 22:12
hn0512

2022-08-01 15:10
顶部