Recently I've built some strategies that use StopMarket and StopLimit orders for entry. However, there have been occasions during high volatility where we are noticing order rejection popups that say something to the effect of "Order Rejected: Buy stop price must be above current market price"
So, I'm playing around with some different ways of managing this case and re-submitting the order upon rejection if an entry signal is still valid.
However, even with this new order rejection and resubmit code, I'm still noticing the error popup. Cand a member of the support team have a look at my approach and let me know what I'm missing?
The core idea is simple,
1) Define a global variable for keeping track of the current order
private Order _order;
2) Assign that variable during the entry call
_order = EnterLongStopMarket(0, true, 1, BO_Level, "RatioBreakoutStrategy");
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment)
{
if (orderState == OrderState.Rejected)
{
if (_order.Name == "RatioBreakoutStrategy") {
_order = EnterLongStopMarket(GetCurrentAsk() + (2*TickSize),GetCurrentAsk() + (2*TickSize), "RatioBreakoutStrategy");
}
}
}

Comment