Hi
I am using the umanaged order framework to create ORB strategies.
Now i keep on getting the “An order has been ignored since the stop price is invalid” this does not really make much sense when you look at my code which is ![]()
protected override void OnExecutionUpdate(Cbi.Execution execution, string executionId, double price, int quantity, Cbi.MarketPosition marketPosition, string orderId, DateTime time)
{
// if the long entry filled, place a profit target and stop loss to protect the order
if (entryLongOrder != null && execution.Order == entryLongOrder)
{
// generate a new oco string for the protective stop and target
string ocoString = string.Format("profitstoploss" + CurrentBar, DateTime.Now.ToString("hhmmssffff"));
longStopLoss = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.StopMarket, 1, 0, entryLongOrder.AverageFillPrice - StopLoss * TickSize, ocoString, "longStopLoss");
longProfitTarget = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.Limit, 1, (entryLongOrder.AverageFillPrice + ProfitTarget * TickSize), 0, ocoString, "longProfitTarget");
}
// reverse the order types and prices for a short
else if (entryShortOrder != null && execution.Order == entryShortOrder)
{
string ocoString = string.Format("profitstoploss" + CurrentBar, DateTime.Now.ToString("hhmmssffff"));
shortStopLoss = SubmitOrderUnmanaged(0, OrderAction.BuyToCover, OrderType.StopMarket, 1, 0, entryShortOrder.AverageFillPrice + StopLoss * TickSize, ocoString, "shortStopLoss");
shortProfitTarget = SubmitOrderUnmanaged(0, OrderAction.BuyToCover, OrderType.Limit, 1, (entryShortOrder.AverageFillPrice - ProfitTarget * TickSize), 0, ocoString, "shortProfitTarget");
}
// I didn't use Order variables to track the stop loss and profit target, but I could have
// Instead, I detect the orders when the fill by their signalName
// (the execution.Name is the signalName provided with the order)
// when the long profit or stop fills, set the long entry to null to allow a new entry
else if (execution.Name == "longProfitTarget" || execution.Name == "longStopLoss" || execution.Name == "shortProfitTarget" || execution.Name == "shortStopLoss")
{
entryLongOrder = null;
entryShortOrder = null;
longStopLoss = null;
shortStopLoss = null;
longProfitTarget = null;
shortProfitTarget = null;
}
}
Everything works fine the first time through second time through no matter what the longStopLoss order is rejected with the invalid price.
Can somebody help here as it does not really make sense that you cannot create an stoplossorder 20 ticks away from the price.Preformatted text