Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Market Position

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

    Market Position

    For some reason my automated strategy with profitable open positions was disabled. When it was quickly re-enabled, the strategy position was flat. The open positions were gone: just forgotten about or ignored, without any exit orders being executed. There was nothing on the chart or in the log file to explain this.

    There continued to be live and profitable positions attached to my Account but that did not prevent the strategy from opening new positions -- despite the "Wait until flat ..." option selected. The execution of initial and trailing stop orders established for the new positions did not exit the pre-disable positions, which were left open even by the ExitOnClose option when the trading session for the instrument ended. It took an intervention external to NT to close these positions, which by then were far from being profitable.

    I understand that on a strategy enable after disable active entry and exit orders are cancelled. But that does not explain the arbitrary erasing of strategy positions. What can a trader do to avoid getting into such a situation? As it stands, the possibility of random strategy disables makes the behavior of automated strategies not fully predictable, I do not think that sync settings which compel the closing of profitable account positions is a solution.

    Surely, the erasure of strategy positions by a disable/enable event is an error (bug) that is easily fixed.

    #2
    Hello Xenophon99,

    Thank you for your post.

    Are you using NinjaTrader 8 or NinjaTrader 7?

    You are using 'Wait until flat before submitting live working orders' what are you using for the Sync Account Position settings?

    I look forward to your response.

    Comment


      #3
      Market Position

      Hello PatrickH,

      In addition to Wait until flat -- and the Market Position is flat that I demand before entering orders in my strategy -- I have SyncAccountPosition=false. I certainly do not want my profitable live positions to be automatically closed by an inexplicable closing of my strategy positions. I cannot imagine what whoever decided that open positions on a disabled strategy should be ignored on re-enable was thinking. I look forward to some enlightenment.

      X

      Comment


        #4
        Market Position

        Sorry, NT 7.

        Comment


          #5
          Hello Xenophon99,

          Thanks for your reply.

          Wait Until Flat will wait until the strategy is in a virtual flat position before it is allowed to submit orders to the live account. When we enable strategy, the logic processes historical data and then proceeds to process realtime data. The historical data that is processed determines a pre-existing position that would be owned by the strategy.

          When Wait Until Flat detects a historical trade, it waits until the strategy reaches a flat position in its trading logic before it can submit live orders.

          When Immediately Submit is used, the strategy attempts to match the any pre-existing live orders with orders generated from processing historical data. It will attempt to resume a position and will immediately start submitting new live orders.

          If historical processing is skipped in a strategy, then the there will be not be any reference for the strategy to generate historical orders or identify a position it may have already had.

          We should also be aware of the Cancel exit orders on disable option which may have canceled your exit orders and left you in an open position.

          Sync Account Position is an additional option meant for syncing the account position to the strategy position.

          We have a tutorial video that demonstrated these behaviors, and I will include additional reference for canceling on disable and syncing account position behaviors. https://www.youtube.com/watch?v=US9c...A14C398CA140D7

          Strategies tab - https://ninjatrader.com/support/help...tegies_tab.htm

          Syncing Account Positions - https://ninjatrader.com/support/help..._positions.htm

          Please let me know if this information does not resolve your inquiry.
          JimNinjaTrader Customer Service

          Comment


            #6
            Market Position

            Hello Jim,

            As I did not want any new positions to be opened until current positions were closed, Sync=WaitUntilFlat was the correct option for me. On a restart of the strategy, this would have left the strategy and account in agreement; 4 short. Though I have little interest in how NT does its housekeeping to keep strategy and account in agreement (I just use the standard and recommended strategy starting options) I could see on the chart and in the log that no order was ever executed to close the existing shorts before four new short positions were opened. The NT software just arbitrarily decided to ignore the first four short positions in the strategy, which it regarded as flat. The account however continued to recognize the four and then eight short positions.

            I am not at all persuaded that other settings of options would have avoided this malfunction (which had very costly consequences for me). I suspect the cause was a mishandled sequence of disables and re-enables of the strategy. I would be reassured to know that the bug has been identified and eliminated. No amount of preaching about starting options will persuade me that the software, or someone else, had the right to close my strategy positions -- and without even notifying me!

            Regards,

            Xenophon99

            Comment


              #7
              Hello Xenophon99,

              As I did not want any new positions to be opened until current positions were closed, Sync=WaitUntilFlat was the correct option for me.
              This is not necessarily true. When a strategy is enabled, it recalculates what any existing positions may be based on the historical data it processes on strategy enablement. This only determines a virtual position from historical data and does not tell the strategy that it has previous orders that should be resumed.

              Processing historical data when we enable only tells the strategy: a) if there is a virtual position that exists from historical data, and b) if there are any historical orders that currently exist. This is not yet tied to previous enablements of the strategy. This information is then used by the Start Behavior to take further action.

              Wait Until Flat will cancel existing orders that were made by the strategy, and wait until the virtual position becomes flat after submitting subsequent orders virtually in addition to any orders that would be pending from the historical data. The previous position is forgotten, recalculated, and then the live orders from the previous instance are cancelled. Wait Until Flat will have no knowledge of a previous instance's active orders. This is what happened with your strategy when you disabled and re-enabled.

              Immediately Submit will attempt to match orders from a previous instance and resume them. As we have observed in the demonstration videos, if we disable the strategy and then re-enable, we can successfully reclaim the strategy's position and orders and then continue trading as if the strategy had not been disabled.

              I'll include the NT8 demonstration for Immediately Submit from my last email. Please not the first enablement of the strategy had the position closed by the Profit Target, and then the second disable and re-enable shows the strategy picking up with the orders it had placed previously.

              NT8 Demo - https://www.screencast.com/t/FUCm2zymF8Cd

              I will also include a demonstration from my colleague Chelsea has presented regarding resuming strategies and the expected behavior of Start Behaviors that may give further insight.

              Chelsea's demonstration - https://www.screencast.com/t/D2GRrGe5MfzJ

              Moving forward, I would strongly advise to run through a similar test as in the first demonstration to see the behavior of the strategy using Immediately Submit and disabling with current active orders and re-enabling. The orders will resume, and the processed historical data will tell the strategy what position it should be in. This will effectively allow the strategy to pick up where it has left off.

              Though I have little interest in how NT does its housekeeping to keep strategy and account in agreement
              In order to use the behaviors NinjaTrader offers, it is required that they be fully understood on how they are expected to operate.

              Please take these same tests with your strategy, and let us know if you have any questions.
              JimNinjaTrader Customer Service

              Comment


                #8
                Market Position

                Hello Jim,

                What is not necessarily true about my preference for WaitUntilFlat behavior rather than ImmediatelySubmit behavior when my strategy is enabled after being disabled? Without stopping trading activities to study the log file, I have no way of knowing how long the strategy has been disabled for, or even that it was disabled at all. Any active trailing stop orders that are protecting possible long or short positions are likely to be inappropriate for current market conditions, so I want them to be cancelled at the exchange and I want fresh trailing stop orders to be calculated and submitted by the exit logic in the OnBarUpdate method of my strategy.

                At this time, I cannot imagine any circumstances in which I would want stale trailing stop exit orders to be restored by ImmediatelySubmit behavior. Nor can I imagine wanting SyncAccountPosition to force my account to close profitable positions so it will be in sync with my NT corrupted strategy position. It was corrupted because instead of being 4 short as it was before being disabled, it was now flat. As my strategy only submits exit orders when it is not flat, no protective cover for the four Account shorts was ever established.

                I would like some assurance that this bug will be fixed, rather than continual lectures about how a differently coded strategy would have behaved differently.


                Xenophon99

                Comment


                  #9
                  Market Position

                  Hello Jim,

                  As Ninja Trader does not employ customer service and development staff who are capable of understanding the WaitUntilFlat option, the account destroying potential of the current implementation of strategy enable is best avoided by selecting the ImmediatelySubmit option. Only that choice is safe.

                  Your efforts at clarification are much appreciated.

                  Xenophon

                  Comment


                    #10
                    Hello Xenophon99,

                    WaitUntilFlat is intended to be used when the Account is flat and you want the strategy to begin submitting live orders only after the strategy's virtual position is flat. Any live orders that were created previously are cancelled, and the strategy uses the simulator to fill orders "virtually" until it reaches a flat position, and then is allowed to submit live.

                    ImmediatelySubmit is intended to be used when the Account position is where you want it at the time you enable your strategy. This will try to match orders that were made previously with orders generated from the strategies historical data processing, which uses OHLC data up until the point the strategy was enabled to determine the strategy position.

                    I have sent you a reply to your email as well. We do understand our start behaviors and how they effect different scenarios. If something is still standing out, we could arrange a call to discuss these behaviors further, or I can have another member of our team reach out to explain differently.

                    If this is the case, please let us know how we can assist you further.
                    JimNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by dappa, Today, 09:18 AM
                    0 responses
                    0 views
                    0 likes
                    Last Post dappa
                    by dappa
                     
                    Started by bill2023, Yesterday, 08:51 AM
                    4 responses
                    22 views
                    0 likes
                    Last Post bltdavid  
                    Started by trilliantrader, Today, 08:16 AM
                    3 responses
                    9 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by NinjaTrader_ChelseaB, 01-08-2017, 06:59 PM
                    79 responses
                    19,662 views
                    5 likes
                    Last Post zrobfrank  
                    Started by funk10101, Today, 08:14 AM
                    3 responses
                    5 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X