I try to get a strategy running with exit short and at the same time setting a new long Limit + Stop . But Managed Order Handling refuse this with a error message. ( An Enter() method to submit an entry order at... has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.)
...
CancelOrder (short);
CancelOrder (shortstop);
if (marketPosition == MarketPosition.short) ExitShort();
longorder = EnterLongLimit(0,true,1, ( BarTief + 1),OrderName );
....
so i try UnManaged like this :
...
// exit short
if (ordershort != null)
{
CancelOrder(ordershort);
CancelOrder(ordershortstop);
}
if(Position.MarketPosition == MarketPosition.Short)
{
shortexit = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, 1, 0, 0,
"", "shortexit");
CancelOrder(ordershortstop);
}
//longlimit + stop
orderlong = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Limit, 1, limit1, 0, "", "long");
orderstop = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.StopMarket, 1,0, stoplimit1, "", "stop");
This works better. But i get a message "... refuse the order ...Margin...."
I guess submit the new buy limit order is faster then cancel the old short position / orders.
How can i cancel the short orders and submit a new long order without waiting a full bar and don`t use Margin for the old and the new order...?
Comment