I want to confirm "order filled" or not, after order sending.
I put Limit order and cancel it after 100 milliseconds.
if order is not filled, TWS accepts cancel.
but already order filled, I have one position.
I want to confirm order status soon, after "p.CancelOrder(_id);".
Please advise.
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using PowerLanguage.TradeManager;
using ATCenterProxy.interop;
namespace PowerLanguage.Strategy
{
public class Test_TradeManager_5 : SignalObject
{
public Test_TradeManager_5(object _ctx):base(_ctx){}
private IOrderMarket buy_order;
protected override void Create()
{
}
protected override void StartCalc()
{
}
protected override void CalcBar()
{
foreach (TradeManager.ITradingProfile p in TradeManager.TradingProfiles)
{
if (p.PluginName.Contains("Interactive Brokers") && p.ConnectionState == ETM_ConnectionChanged.eTM_CC_Connected)
{
Output.WriteLine("Start");
MCSymbolInfo msymbInfo = new MCSymbolInfo();
msymbInfo.symbol.BigPointValue = Bars.Info.BigPointValue;
msymbInfo.symbol.MinMove = (int)Bars.Info.MinMove;
msymbInfo.symbol.PriceScale = Bars.Info.PriceScale;
msymbInfo.symbol.SymbolCategory = MTPA_MCSymbolCategories.eMTPA_MCSC_FUTURE;
msymbInfo.symbol.SymbolDescription = Bars.Info.Description; /*"USD DEC13 ES Futures ESZ3 MULT:50";*/
msymbInfo.data_feed = "Interactive Brokers";
msymbInfo.symbol.SymbolExchange = "GLOBEX";
msymbInfo.symbol.SymbolExpiry = Convert.ToDateTime("20.12.2013");
msymbInfo.symbol.SymbolName = Bars.Info.Name;
msymbInfo.symbol.SymbolRoot = "ES";
p.CurrentSymbol = msymbInfo;
OrderParams _pparam = new OrderParams();
_pparam.action = MTPA_OrdrActn.eMTPA_OA_Buy;
double _oPrice = Bars.LowValue - 0.5;
_pparam.category = MTPA_OrdrCtgry.eMTPA_OC_Limit;
_pparam.contracts = 10;
_pparam.tif = MTPA_OrdrTimeInForce.eMTPA_TIF_DAY;
_pparam.limit_price = _oPrice;
int _id = p.PlaceOrder(_pparam);
System.Threading.Thread.Sleep(100);
p.CancelOrder(_id);
////////////////////////////////////////////////////
//
// I want to confirm oder status in here.
// the above order is filled or not...
// Because, if this order is filled, I want to put other order soon.
//
////////////////////////////////////////////////////
Output.WriteLine("Success!");
}
}
}
}
}