• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Internal Order Handling Rules violation only logged once RC1

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Internal Order Handling Rules violation only logged once RC1

    I'm calling the highlighted rule 'rule 3'
    For the most part, you do not need to be intimately familiar with these rules as you develop your strategies. It is all taken care of for you internally within a strategy. If a rule is violated, you will be notified through an error log in the Control Center Log tab.

    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
    The bug:
    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)
    Flat at bar 0, 26 Sep 2016 06:00: EnterLongLimit(100000, 0.001)
    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'
    Three violations of rule 3 occured for the rows covered by this extract, but only the first (highlighted) has been logged by TraceOrders (and Log)..

    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.
    Attached Files

    #2
    Hello DaveE,

    Thank you for the additional report.

    I will forward this information to development.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      Thank you for your patience.

      Your orders are expiring after one bar after the initial 'Internal Order Handling Rules' violation. Set your limit orders to isLiveUntilCancelled = true and test again. See the overloads at the following link for more information.
      Patrick H.NinjaTrader Customer Service

      Comment


        #4
        I attach a script that demonstrates the bug more clearly that the script in post 1.
        Please forward it to your testing department.
        Here is sample output running it on USDJPY 60min TF:
        DataLoaded
        Historical
        **Flat at CurrentBar=0, 09 Oct 2016 23:00: EnterLongLimit(100000, 0.001)
        09/10/2016 23:00:00 Strategy 'sTestLimitError7/-1': Entered internal SubmitOrderManaged() method at 09/10/2016 23:00:00: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=100,000 LimitPrice=0.00'1 StopPrice=0 SignalName='' FromEntrySignal=''
        OnOrderUpdate Name=Buy, OrderState=Submitted
        OnOrderUpdate Name=Buy, OrderState=Accepted
        OnOrderUpdate Name=Buy, OrderState=Working
        **Flat at CurrentBar=1, 10 Oct 2016 00:00: EnterShortLimit(100000, 206.342)
        but there is still an active Long order that is due to expire, but not yet cancelled, so 'rule 3' SHOULD log an error
        10/10/2016 00:00:00 Strategy 'sTestLimitError7/-1': Entered internal SubmitOrderManaged() method at 10/10/2016 00:00:00: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100,000 LimitPrice=206.34'2 StopPrice=0 SignalName='' FromEntrySignal=''
        10/10/2016 00:00:00 Strategy 'sTestLimitError7/-1': Ignored SubmitOrderManaged() method at 10/10/2016 00:00:00: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100,000 LimitPrice=206.34'2 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 'sTestLimitError7/-1': An Enter() method to submit an entry order at '10/10/2016 00:00:00' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.

        10/10/2016 00:00:00 Strategy 'sTestLimitError7/-1': Cancelled expired order: BarsInProgress=0, orderId='NT-00000-2589' 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-10-09 23:00:00' gtd='2099-12-01' statementDate='2016-10-19'
        OnOrderUpdate Name=Buy, OrderState=CancelPending
        OnOrderUpdate Name=Buy, OrderState=CancelSubmitted
        OnOrderUpdate Name=Buy, OrderState=Cancelled
        Above my code has detected at CurrentBar=1 that there is a violation of the current rule 3, and NT does log this violation correctly (highlighted green).
        But the next time exactly the same sequence occurs NT fails to log the violation
        **Flat at CurrentBar=2, 10 Oct 2016 01:00: EnterLongLimit(100000, 0.001)
        10/10/2016 01:00:00 Strategy 'sTestLimitError7/-1': Entered internal SubmitOrderManaged() method at 10/10/2016 01:00:00: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=100,000 LimitPrice=0.00'1 StopPrice=0 SignalName='' FromEntrySignal=''
        OnOrderUpdate Name=Buy, OrderState=Submitted
        OnOrderUpdate Name=Buy, OrderState=Accepted
        OnOrderUpdate Name=Buy, OrderState=Working
        **Flat at CurrentBar=3, 10 Oct 2016 02:00: EnterShortLimit(100000, 206.226)
        but there is still an active Long order that is due to expire, but not yet cancelled, so 'rule 3' SHOULD log an error
        10/10/2016 02:00:00 Strategy 'sTestLimitError7/-1': Entered internal SubmitOrderManaged() method at 10/10/2016 02:00:00: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=100,000 LimitPrice=206.22'6 StopPrice=0 SignalName='' FromEntrySignal=''
        10/10/2016 02:00:00 Strategy 'sTestLimitError7/-1': Cancelled expired order: BarsInProgress=0, orderId='NT-00001-2589' 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-10-10 01:00:00' gtd='2099-12-01' statementDate='2016-10-19'
        OnOrderUpdate Name=Buy, OrderState=CancelPending
        OnOrderUpdate Name=Buy, OrderState=CancelSubmitted
        OnOrderUpdate Name=Buy, OrderState=Cancelled
        You can see below (highlighted in pink) that NT SubmitOrderManaged() has taken the instruction to go Short, BUT THIS DISAPPEARS INTO AN INFORMATION BLACK HOLE. There is no further action on either attempting to progress this instruction or reporting an error or violation of rule 3.
        The same bug occurs on all further occurrences.
        This bug is still in RC2
        Attached Files
        Last edited by DaveE; 10-19-2016, 08:22 AM. Reason: attachment

        Comment


          #5
          Hello DaveE,

          Thank you for your response.

          This would be the same case as the original file even with the additional output you added. I simplified the system so that I could see it more clearly on my end and I do in fact see that the message is only reported once - however this is the same in NinjaTrader 7. So is your note to suggest that each internal order handling rule violation that is a repeat of the last order's message to repeat in the Output?
          Patrick H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by JohnAymin, Today, 02:38 PM
          0 responses
          3 views
          0 likes
          Last Post JohnAymin  
          Started by Rmos22, Today, 02:20 PM
          2 responses
          14 views
          0 likes
          Last Post Rmos22
          by Rmos22
           
          Started by sawtooth500, Today, 12:59 PM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Spencer  
          Started by Steve L, Yesterday, 09:36 PM
          1 response
          20 views
          0 likes
          Last Post NinjaTrader_Kate  
          Started by MichaelAlexander, 04-25-2017, 03:28 AM
          9 responses
          1,171 views
          0 likes
          Last Post dani neira  
          Working...
          X