The following rules are true per unique signal name:
Methods that generate orders to enter a position will be ignored if:
• A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
• A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction
• The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction
• The entry signal name is not unique
If rule 3 is violated during the running of a strategy it only gets logged on the first occurence (subsequent occurences are 'silent'). So there is only one entry in TraceOrders output or the Log regardless of how many violations occur.
Effect of bug: Where running stategies are violating the rule, the ignored limit order reversal attempts are not being logged as an error (except the first one). Because this first violation is likely to occur during historical processing, subsequent violations during live running may not come to the attention of the user. In general problems with strategies are harder to diagnose. Some examples are in this thread.
Steps to reproduce:
Run the attached strategy (only needs a day's input in Strategy Analyzer, say 60 minute TF forex)
The Output will look something like this (truncated)
26/09/2016 06:00:00 Strategy 'sTestLimitError5/-1': Entered internal SubmitOrderManaged() method at 26/09/2016 06:00:00: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=100,000 LimitPrice=0.00'1 StopPrice=0 SignalName='' FromEntrySignal=''
Flat at bar 1, 26 Sep 2016 07:00: EnterShortLimit(100000, 202.156)
26/09/2016 07:00:00 Strategy 'sTestLimitError5/-1': Entered internal SubmitOrderManaged() method at 26/09/2016 07:00:00: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100,000 LimitPrice=202.15'6 StopPrice=0 SignalName='' FromEntrySignal=''
26/09/2016 07:00:00 Strategy 'sTestLimitError5/-1': Ignored SubmitOrderManaged() method at 26/09/2016 07:00:00: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100,000 LimitPrice=202.15'6 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 'sTestLimitError5/-1': An Enter() method to submit an entry order at '26/09/2016 07:00:00' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.
26/09/2016 07:00:00 Strategy 'sTestLimitError5/-1': Cancelled expired order: BarsInProgress=0, orderId='NT-00000-3263' account='Backtest' name='Buy' orderState=Working instrument='USDJPY' orderAction=Buy orderType='Limit' limitPrice=0.001 stopPrice=0 quantity=100,000 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2016-09-26 06:00:00' gtd='2099-12-01' statementDate='2016-09-30'
Flat at bar 2, 26 Sep 2016 08:00: EnterLongLimit(100000, 0.001)
26/09/2016 08:00:00 Strategy 'sTestLimitError5/-1': Entered internal SubmitOrderManaged() method at 26/09/2016 08:00:00: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=100,000 LimitPrice=0.00'1 StopPrice=0 SignalName='' FromEntrySignal=''
Flat at bar 3, 26 Sep 2016 09:00: EnterShortLimit(100000, 201.728)
26/09/2016 09:00:00 Strategy 'sTestLimitError5/-1': Entered internal SubmitOrderManaged() method at 26/09/2016 09:00:00: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100,000 LimitPrice=201.72'8 StopPrice=0 SignalName='' FromEntrySignal=''
26/09/2016 09:00:00 Strategy 'sTestLimitError5/-1': Cancelled expired order: BarsInProgress=0, orderId='NT-00001-3263' account='Backtest' name='Buy' orderState=Working instrument='USDJPY' orderAction=Buy orderType='Limit' limitPrice=0.001 stopPrice=0 quantity=100,000 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2016-09-26 08:00:00' gtd='2099-12-01' statementDate='2016-09-30'
Flat at bar 4, 26 Sep 2016 10:00: EnterLongLimit(100000, 0.001)
26/09/2016 10:00:00 Strategy 'sTestLimitError5/-1': Entered internal SubmitOrderManaged() method at 26/09/2016 10:00:00: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=100,000 LimitPrice=0.00'1 StopPrice=0 SignalName='' FromEntrySignal=''
Flat at bar 5, 26 Sep 2016 11:00: EnterShortLimit(100000, 201.222)
26/09/2016 11:00:00 Strategy 'sTestLimitError5/-1': Entered internal SubmitOrderManaged() method at 26/09/2016 11:00:00: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100,000 LimitPrice=201.22'2 StopPrice=0 SignalName='' FromEntrySignal=''
26/09/2016 11:00:00 Strategy 'sTestLimitError5/-1': Cancelled expired order: BarsInProgress=0, orderId='NT-00002-3263' account='Backtest' name='Buy' orderState=Working instrument='USDJPY' orderAction=Buy orderType='Limit' limitPrice=0.001 stopPrice=0 quantity=100,000 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2016-09-26 10:00:00' gtd='2099-12-01' statementDate='2016-09-30'
Im requesting this bug fix because I assume its a quick fix that should be ready for the next release, whereas my suggested improvement of the rule might take longer.
Comment