Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unexpected Close of Strategy Position

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

    Unexpected Close of Strategy Position

    I have trouble with strategies that have open historical positions.

    The simple test strategy here demonstrates the problem. If the strategy has an open (strategy) postion at the moment of starting it on real time data, the opened position gets closed (see screenshot).

    Both NT6 and NT7 on sim101 and on live accounts show the same behaviour. I am using "Immediately submit live working orders".

    What am I doing wrong?
    Attached Files

    #2
    Hi vassil,

    This is likely because you are not using the "Sync Account Position" option when you set up the strategy.

    You may be running in to one of the issues described here...


    With NinjaTrader 7, you have an option to "Sync Account Position" when you apply a strategy.
    TimNinjaTrader Customer Service

    Comment


      #3
      Hi Tim,

      thank you for the reply.

      I mean, the pure strategy position gets closed. I don't try to synchronize with the real position. NT6 can't synchronize; in NT7 I have Sync account position = false.
      Last edited by vassil; 04-06-2010, 02:34 PM.

      Comment


        #4
        Vassil, if the strategy position is being closed, does that make the strategy start running as it should? Have you tested it until a "real" position is opened or closed?

        If you're running "Immediately submit live working orders", that would mean that as soon as the strategy is started, the strategy position is flattened because the strategy is immediately trying to get synchronized to the market by submitting an order.

        I ran your strategy through a simple test:
        1) Buy 1 ES contract to establish an account position
        2) Open a chart of ES and put your strategy on it with sync acct position = false.
        3) Enable strategy
        4) The "closed position" marker appears on the chart
        5) Account position is still long 1 ES contract, as it should be.

        Have you tried the other combinations of sync account and immediately submit orders/wait?

        As a side note, it could be the code that closes the position because of the exclusive use of Stop entry orders (and the unique combination of OR statements). For example, SampleMACrossOver does not exhibit the same behavior as your strategy upon start up. It retains the strategy position.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Austin, thank you very much for your extenive check of the problem.

          What you describe (1..5) is precisely what happens. The account position is correct, but the strategy position is not - it gets closed. Obviously a strategy which relies on the current market position cannot run correctly after that point.

          The SampleMACrossOver retains position but it uses just market orders, which wouldn't work for my strategy.

          Therefore, I tried to localize further the problem (see MyTest2.cs).

          This simple strategy goes short market after 9:00.
          Then it places an ExitShortStop(xxx) 3 points above the entry (on ES).
          This works correctly (see correct.png)

          The alternative version (see lines 66 and 67 in MyTest2.cs) places an EnterLongStop(xxx) instead of ExitShortStop(xxx). Now I get the "Close position" issue (see wrong.png).

          I did both tests with "Immediately submit live working historical orders" and "Sync account position" = false.

          What can I do from this point on?
          Attached Files

          Comment


            #6
            Hi vassil,

            I'm going to continue to try to reproduce this and will respond asap.

            Please continue to update me.
            TimNinjaTrader Customer Service

            Comment


              #7
              Hi Tim,
              I've just tried: the state of "Sync account position" has no influence of the behavior, as allready described. The syncing itself seems to work in the situation where MyTest2.cs also does.

              Comment


                #8
                Hi vassil,

                Someone will respond first thing tomorrow morning. Thank you for your patience.
                TimNinjaTrader Customer Service

                Comment


                  #9
                  vassil, from the logs two points standing out - first you get a some ignored orders because the submitted price at was out of line and thus resulted in getting ignored by NT. This is related to the second point of submitting a stop price of literally 3, so you would need to check into your custom and debug as needed to submit at correct prices, also for the historical OnBarUpdate() part.

                  Comment


                    #10
                    Bertrand, thank you for the message.

                    I am not sure how you conclude that there are any cancelled orders. Could you please clarify. (I have attached the output from TraceOrders=true, but may be I oversee something.)

                    As far as the the stop price: it is not just 3, it is entryPrice + 3 ES points.
                    The strategy sells just one contract, the entryPrice and is a valid price for ES as there are no parial filles.

                    The problem is obviously reproducable, at least Austin could do it. Are you also able to reproduce it? Alternatively, are there some other tests I can perform in order to fix the problem?
                    Attached Files
                    Last edited by vassil; 04-09-2010, 12:15 AM.

                    Comment


                      #11
                      Ok, I started your strategy on the ES 24 hrs chart without any sync and the strategy position right now is long (which the strategies tab also confirms).

                      The moment I start up your strategy I get the error in the log tab as shown, which means you need to debug the stop prices you submit at.
                      Attached Files

                      Comment


                        #12
                        Thank you, Bertrand. Now I know what you mean. I will try to understand what happes there.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by argusthome, 03-08-2026, 10:06 AM
                        0 responses
                        110 views
                        0 likes
                        Last Post argusthome  
                        Started by NabilKhattabi, 03-06-2026, 11:18 AM
                        0 responses
                        59 views
                        0 likes
                        Last Post NabilKhattabi  
                        Started by Deep42, 03-06-2026, 12:28 AM
                        0 responses
                        37 views
                        0 likes
                        Last Post Deep42
                        by Deep42
                         
                        Started by TheRealMorford, 03-05-2026, 06:15 PM
                        0 responses
                        41 views
                        0 likes
                        Last Post TheRealMorford  
                        Started by Mindset, 02-28-2026, 06:16 AM
                        0 responses
                        78 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Working...
                        X