I have a strategy that onBarUpdate() determines the market position before trading so as to exit any opposite position first. However, during a backtest a long trade was ignored because a short was open, or so I believe. Here's the trace order output:
3/17/2009 1:23:00 AM Entered internal PlaceOrder() method at 3/17/2009 1:23:00 AM: Action=Buy OrderType=Limit Quantity=0.02M LimitPrice=1.3014 StopPrice=0 SignalName='LongX' FromEntrySignal=''
3/17/2009 1:23:00 AM Ignored PlaceOrder() method at 3/17/2009 1:23:00 AM: Action=Buy OrderType=Limit Quantity=0.02M LimitPrice=1.3014 StopPrice=0 SignalName=LongX' FromEntrySignal='' Reason='An Enter() method to submit an entry order has been ignore. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.'
My OnBarUpdate() code is this:
if (Position.MarketPosition == MarketPosition.Short) {
if (someCondition) // long entry signal
{
exitOrder = ExitShort(Position.Quantity, "XShrtOnLongX", "ShortX");
if (stopOrder != null)
CancelOrder(stopOrder);
entryOrder = EnterLongLimit(simLotsTraded, GetCurrentBid(), "LongX");
As you can see, it should exit before entering and ususally does. However this time it did not. How can I deal with this?
Comment