如何使用雷达屏实时监控并实时下单?
雷达屏中可以插入指标,但是不能使用保留字buy、sell等,所以只能在指标中使用OrderTicket在产生交易信号的时候发送委托。
示例1:使用OrderTicket在指标中发送委托
注意:无须为指标绑定AnalysisTechnique_Initialized主函数事件
using guosen;
using elsystem;
using tsdata.common;
using tsdata.marketdata;
vars:
guosen.OrderTicket otk1(null),
guosen.Order ord(null),
string accID("410038122059");
method void sendOrder(string acct)
begin
otk1 = new guosen.OrderTicket;
otk1.Symbol = "000002.SZ";
otk1.Quantity = 12100;
otk1.Account = acct;
otk1.Action = OrderAction.Buy;
otk1.SymbolType = tsdata.common.SecurityType.Stock;
otk1.Type = tsdata.trading.OrderType.Limit;
otk1.Duration="GFD";
otk1.LimitPrice = 26.28;
ord = otk1.Send();//发单
ord.Updated += ord_Updated;
ord.Cancel();//撤单
end;
Method void ord_Updated(elsystem.Object sender,guosen.OrderUpdatedEventArgs args)
Begin
print(DateTime.Now.ToString()+ "," +args.OrderID.ToString()+","+args.State.ToString()+","+ args.Order.StateDetail.ToString()+","+args.Message);
End;
if(Close > highest(close[1],10))then
Begin
plot1(True);
sendOrder(accID);
End;
//打印语句输出栏结果示例: