Sometimes, when flat a limit buy will be placed one bar, not get filled, then on the next bar a limit sell will be placed and will be ignored due to order handling rules.
I can't figure out what rule its violating since the strategy is flat and the limit order that was not filled should have been cancelled since its the next bar.
Is there any to accomplish what I'd like to do using managed orders?
This code will reproduce the error for the second trade:
[FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] TEST2 : Strategy[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] Initialize()[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [SIZE=2][FONT=Courier New]CalculateOnBarClose = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [SIZE=2][FONT=Courier New]TraceOrders = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnBarUpdate()[/SIZE][/FONT] [SIZE=2][FONT=Courier New]{[/FONT][/SIZE] [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (CurrentBar % [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] == [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT] [SIZE=2][FONT=Courier New]EnterLongLimit([/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/FONT] [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]EnterShortLimit([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2].MaxValue);[/SIZE][/FONT] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [SIZE=2][FONT=Courier New]}[/FONT][/SIZE] [/SIZE][/FONT]
1/3/2011 11:15:00 AM Entered internal PlaceOrder() method at 1/3/2011 11:15:00 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=100 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='' 1/3/2011 11:20:00 AM Entered internal PlaceOrder() method at 1/3/2011 11:20:00 AM: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100 LimitPrice=Infinity StopPrice=0 SignalName='' FromEntrySignal='' 1/3/2011 11:20:00 AM Ignored PlaceOrder() method at 1/3/2011 11:20:00 AM: Action=SellShort OrderType=Limit Quantity=100 LimitPrice=Infinity StopPrice=0 SignalName=Sell short' FromEntrySignal='' Reason='An Enter() method to submit an entry order has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.' **NT** An Enter() method to submit an entry order at '1/3/2011 11:20:00 AM' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation. 1/3/2011 11:20:00 AM Cancelled expired order: BarsInProgress=0: Order='NT-00000/Backtest' Name='Buy' State=Working Instrument='SPY' Action=Buy Limit price=0 Stop price=0 Quantity=100 Strategy='TEST2' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='555b7ccaa03548fa8be98c0032d836d4' Gtd='12/1/2099 12:00:00 AM' 1/3/2011 11:25:00 AM Entered internal PlaceOrder() method at 1/3/2011 11:25:00 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=100 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='' 1/3/2011 11:30:00 AM Entered internal PlaceOrder() method at 1/3/2011 11:30:00 AM: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100 LimitPrice=Infinity StopPrice=0 SignalName='' FromEntrySignal='' 1/3/2011 11:30:00 AM Cancelled expired order: BarsInProgress=0: Order='NT-00001/Backtest' Name='Buy' State=Working Instrument='SPY' Action=Buy Limit price=0 Stop price=0 Quantity=100 Strategy='TEST2' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='c410c1ba1de144a3a7c8bfdcab39e6d1' Gtd='12/1/2099 12:00:00 AM' 1/3/2011 11:35:00 AM Entered internal PlaceOrder() method at 1/3/2011 11:35:00 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=100 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='' 1/3/2011 11:40:00 AM Entered internal PlaceOrder() method at 1/3/2011 11:40:00 AM: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100 LimitPrice=Infinity StopPrice=0 SignalName='' FromEntrySignal='' 1/3/2011 11:40:00 AM Cancelled expired order: BarsInProgress=0: Order='NT-00002/Backtest' Name='Buy' State=Working Instrument='SPY' Action=Buy Limit price=0 Stop price=0 Quantity=100 Strategy='TEST2' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='eb83fbc84aae4dcab5597309d3774261' Gtd='12/1/2099 12:00:00 AM' 1/3/2011 11:45:00 AM Entered internal PlaceOrder() method at 1/3/2011 11:45:00 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=100 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='' 1/3/2011 11:50:00 AM Entered internal PlaceOrder() method at 1/3/2011 11:50:00 AM: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100 LimitPrice=Infinity StopPrice=0 SignalName='' FromEntrySignal='' 1/3/2011 11:50:00 AM Cancelled expired order: BarsInProgress=0: Order='NT-00003/Backtest' Name='Buy' State=Working Instrument='SPY' Action=Buy Limit price=0 Stop price=0 Quantity=100 Strategy='TEST2' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='5b0d1604fcac488089659be56cdca8dd' Gtd='12/1/2099 12:00:00 AM' 1/3/2011 11:55:00 AM Entered internal PlaceOrder() method at 1/3/2011 11:55:00 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=100 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='' 1/3/2011 12:00:00 PM Entered internal PlaceOrder() method at 1/3/2011 12:00:00 PM: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100 LimitPrice=Infinity StopPrice=0 SignalName='' FromEntrySignal='' 1/3/2011 12:00:00 PM Cancelled expired order: BarsInProgress=0: Order='NT-00004/Backtest' Name='Buy' State=Working Instrument='SPY' Action=Buy Limit price=0 Stop price=0 Quantity=100 Strategy='TEST2' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='df5c5a47a6594110bf59812e747a492f' Gtd='12/1/2099 12:00:00 AM' 1/3/2011 12:05:00 PM Entered internal PlaceOrder() method at 1/3/2011 12:05:00 PM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=100 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal='' 1/3/2011 12:10:00 PM Entered internal PlaceOrder() method at 1/3/2011 12:10:00 PM: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100 LimitPrice=Infinity StopPrice=0 SignalName='' FromEntrySignal=''
Comment