I see in many cases when OIF record is placed it works and in most cases its Filling the Buy Order but rejecting the Target and Stop.
Attached is the log file extract.
What can be the reason ?
try{
BarsRequest barsRequest = new BarsRequest(NinjaTrader.Cbi.Instrument.GetInstrume nt(instrument), 1);
// Parametrize your request.
barsRequest.BarsPeriod = new BarsPeriod { BarsPeriodType = BarsPeriodType.Day, Value = 1 };
barsRequest.TradingHours = TradingHours.Get("Default 24 x 7");
// Request the bars
barsRequest.Request(new Action<BarsRequest, ErrorCode, string>((bars, errorCode, errorMessage) =>
{
if (bars==null || bars.Bars==null || bars.Bars.Count==0)
{
// Handle any errors in requesting bars here
NinjaTrader.NinjaScript.NinjaScript.Log(string.For mat("No Market data subscription hence Order Rejected: {0} Error Code, {1} Error Message, {2} Bars, {3}, {4}",
errorCode!=null?errorCode.ToString():"Null", errorMessage!=null?errorMessage:"Null", bars!=null && bars.Bars!=null?bars.Bars.Count.ToString():"Null", account, instrument), LogLevel.Error);
insertOrderForOltp(account, instrument, Action, Quantity, OrderType,0,0,TIF,"",OrderID, "Entry", "Rejected", 0, StrategyTemplate);
return;
}
else
{
String fileName = ""+Guid.NewGuid();
using (System.IO.StreamWriter file = new System.IO.StreamWriter(incomingDir+"\\oif_"+fileNa me+".txt"))
file.WriteLine(string.Format("{0};{1};{2};{3};{4}; {5};{6};{7};{8};{9};{10};{11};{12}", Command, account,instrument,Action,Quantity,OrderType,"","" ,TIF,OcoID,OrderID,StrategyTemplate,StrategyID));
return;
}
}));
} catch(Exception ex) {NinjaTrader.NinjaScript.NinjaScript.Log("Error Verifying MarketData Subscription: "+account+" "+instrument+"\n"+ex.StackTrace, LogLevel.Error); }
Comment