EnterLongLimit(int quantity, double limitPrice)
or
EnterShortLimit(int quantity, double limitPrice)
is called, and the order is not filled, the limit order does not seem to be auto-cancelled.
This causes the next limit order to be rejected, by NT's 'Internal Order Handling Rules' (if its in the opposite direction).
Subsequent cases are auto-cancelled
eg EnterLongLimit(int quantity, double limitPrice) one bar (first time no fill), followed by EnterShortLimit(int quantity, double limitPrice) next bar will cause the error
This problem might have existed in previous versions, but I did not identify the cause before.
I attach a simple strategy that demonstrates the bug.
This strategy starts with a small distance from close to limit price, so the first few orders are likely to be filled, but as the distance increases each bar you will soon get a limit that is not filled.
Steps to reproduce the bug:
Run the attached strategy (say in Strategy Analyzer) any instrument/TF (I used Forex, 15 minute) so long as there are at least 50 bars in your data.
Check the output (search for 'ignored').
Expected result:
When EnterLongLimit(int quantity, double limitPrice)
or
EnterShortLimit(int quantity, double limitPrice)
is not filled it should be auto-cancelled at the end of the bar (so an order the next bar in the opposite direction will be allowed).
With TraceOrders=true I expect to see 'Cancelled expired order' after each bar where limit order was not filled.
Actual result:
The first time this happens the auto-cancel does not work (subsequent times it does).
(search Output for 'ignored' you will see the error at the first occurrence)
Example output:
22/09/2016 14:05:00 Strategy 'sTestLimitError1/-1': Entered internal SubmitOrderManaged() method at 22/09/2016 14:05:00: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=100,000 LimitPrice=100.43'1 StopPrice=0 SignalName='' FromEntrySignal=''
Flat at 22 Sep 2016 14:30: EnterShortLimit(100000, 100.857)
22/09/2016 14:30:00 Strategy 'sTestLimitError1/-1': Entered internal SubmitOrderManaged() method at 22/09/2016 14:30:00: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100,000 LimitPrice=100.85'7 StopPrice=0 SignalName='' FromEntrySignal=''
22/09/2016 14:30:00 Strategy 'sTestLimitError1/-1': Ignored SubmitOrderManaged() method at 22/09/2016 14:30:00: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100,000 LimitPrice=100.85'7 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.'
Strategy 'sTestLimitError1/-1': An Enter() method to submit an entry order at '22/09/2016 14:30:00' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.
22/09/2016 14:30:00 Strategy 'sTestLimitError1/-1': Cancelled expired order: BarsInProgress=0, orderId='NT-00006-486' account='Backtest' name='Buy' orderState=Working instrument='USDJPY' orderAction=Buy orderType='Limit' limitPrice=100.431 stopPrice=0 quantity=100,000 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2016-09-22 14:05:00' gtd='2099-12-01' statementDate='2016-09-26'
Flat at 22 Sep 2016 14:55: EnterLongLimit(100000, 100.272)
Comment