Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CLOSESTRATEGY COMMAND doesn´t work

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

    CLOSESTRATEGY COMMAND doesn´t work

    I traded today a strategy with *.txt files (send from eSignal to NT), the position was opened, but not closed.

    The CLOSESTRATEGY COMMAND doesn´t closed the position about the one open FDAX-Future, only the target and the stop orders where canceled.

    Here you can see the logfile(I changed only account number). Why was the position not closed?

    Torso


    14/08/2007 15:35:59 Order Order='776029134/Uxxxx' Name='Stop1' New State=Cancelled Instrument='FDAX 09-07' Action=Sell Limit price=0 Stop price=7496.5 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error='Order Storniert - Grund: (202)'
    14/08/2007 15:35:59 Order Order='776029135/Uxxxx' Name='Target1' New State=Cancelled Instrument='FDAX 09-07' Action=Sell Limit price=7519 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error='Order Storniert - Grund: (202)'
    14/08/2007 15:35:58 Order Order='776029135/Uxxxx' Name='Target1' New State=PendingCancel Instrument='FDAX 09-07' Action=Sell Limit price=7519 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    14/08/2007 15:35:58 Order Order='776029134/Uxxxx' Name='Stop1' New State=PendingCancel Instrument='FDAX 09-07' Action=Sell Limit price=0 Stop price=7496.5 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    14/08/2007 15:35:58 Strategy Cancelling any remaining strategy orders
    14/08/2007 15:35:58 ATI AT 'CLOSESTRATEGY;;;;;;;;;;;;DAX_1min_Target.7.5_Stop .15' processing
    14/08/2007 15:32:05 Order Order='776029135/Uxxxx' Name='Target1' New State=Working Instrument='FDAX 09-07' Action=Sell Limit price=7519 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    14/08/2007 15:32:05 Order Order='776029135/Uxxxx' Name='Target1' New State=Accepted Instrument='FDAX 09-07' Action=Sell Limit price=7519 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    14/08/2007 15:32:05 Order Order='776029134/Uxxxx' Name='Stop1' New State=Working Instrument='FDAX 09-07' Action=Sell Limit price=0 Stop price=7496.5 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    14/08/2007 15:32:05 Order Order='776029134/Uxxxx' Name='Stop1' New State=Accepted Instrument='FDAX 09-07' Action=Sell Limit price=0 Stop price=7496.5 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    14/08/2007 15:32:04 Position Instrument='FDAX 09-07' Account='Uxxxx' Avg price=7511.5544 Quantity=1 Market position=Long Operation=Insert Currency=Euro
    14/08/2007 15:32:03 Order Order='9df708400e124fc3b88e310293a23ab0/Uxxxx' Name='Target1' New State=PendingSubmit Instrument='FDAX 09-07' Action=Sell Limit price=7519 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
    14/08/2007 15:32:03 Order Order='303fabc33a8d465d8b17a4b4e48fea28/Uxxxx' Name='Stop1' New State=PendingSubmit Instrument='FDAX 09-07' Action=Sell Limit price=0 Stop price=7496.5 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
    14/08/2007 15:32:03 Execution Execution='FDAX 09-07/0000e7d2.4519c8ad.01.01' Instrument='FDAX 09-07' Account='Uxxxx' Exchange=Eurex Price=7511.5 Quantity=1 Market position=Long Operation=Insert Order='776029133' Time='14/08/2007 15:32:03'
    14/08/2007 15:32:03 Order Order='776029133/Uxxxx' Name='Entry' New State=Filled Instrument='FDAX 09-07' Action=Buy Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=1 Fill price=7511.5 Error=NoError Native error=''
    14/08/2007 15:32:03 Order Order='776029133/Uxxxx' Name='Entry' New State=Working Instrument='FDAX 09-07' Action=Buy Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
    14/08/2007 15:32:02 Order Order='776029133/Uxxxx' Name='Entry' New State=Accepted Instrument='FDAX 09-07' Action=Buy Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
    14/08/2007 15:32:02 Order Order='11ac3d73a5364c6ebc91b17500842c25/Uxxxx' Name='Entry' New State=PendingSubmit Instrument='FDAX 09-07' Action=Buy Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
    14/08/2007 15:32:02 Order Submitting order with strategy
    14/08/2007 15:32:02 ATI AT 'PLACE;Uxxxx;FDAX 09-07;BUY;1;MARKET;0;0;DAY;;DAX_1min_Target.7.5_Stop. 15;NT_DAX_1min_Target.7.5_Stop.15;DAX_1min_Target. 7.5_Stop.15' processing

    #2
    At quick glance, it looks like both your stop and limit orders were filled before the order could be cancelled. This can happen if your stop/target are very close to each other and the market moves quickly and fills both orders before the cancellation requests can be confirmed.
    RayNinjaTrader Customer Service

    Comment


      #3
      dont´t think so, that both orders (limit/stop) were filled. I checked the trades and it was only one trade (entry FDAX long, 15:32:02).

      The limit order was 7496.0 and the stop order was 7519. It is not close to each other ( I traded the FDAX, and this is a difference from 26ticks). The market was not near the target order (highest high during the strategy time was 7513.5).

      The matter is, why is the position not closed at the IB account?

      The position was after sending the CLOSESTRATEGY further open (I checked the trades, no others sell/buy), although the market was under the (old) stop-order (but the stop order was canceled from NT).

      Torso
      Last edited by Torso; 08-14-2007, 09:08 AM.

      Comment


        #4
        Sorry, I misread the log information.

        I can see the problem but can't see how this could happen, I tried to reproduce on my development PC's and it worked as expected.

        - Is this the only time this has happened or can you reproduce it?
        - Can you test it on the Sim101 account, does it work or not?
        RayNinjaTrader Customer Service

        Comment


          #5
          Hi Ray,

          I tryed it again, it works proper (and also in the past the system works during the last 3 weeks proper). Here the log-file from now, I tested it 5min ago.

          Additionally I checked the chart during the time between entry up to the closestrategy-file (not the trade now, the failing trade), also the ticks from eSignal to understand the mistake. I think, that the price from FDAX was near or the same like the stop order, than the CLOSESTRATEGY file was generated from the eSignal chart and sended to NT.

          Is it possible, that the stop order and the CLOSESTRATEGY order clashed?


          See attached the last test, it works fine ( I tested twice, the first one is atteched)

          Torso


          14/08/2007 17:41:19 Execution Execution='FDAX 09-07/0000e9b5.446a2955.01.01' Instrument='FDAX 09-07' Account='Uxxxxx' Exchange=Eurex Price=7473.5 Quantity=1 Market position=Short Operation=Insert Order='1038173143' Time='14/08/2007 17:41:19'
          14/08/2007 17:41:19 Order Order='1038173143/Uxxxxx' Name='Target1' New State=Filled Instrument='FDAX 09-07' Action=Sell Limit price=7466 Stop price=0 Quantity=1 Type=Limit Filled=1 Fill price=7473.5 Error=NoError Native error=''
          14/08/2007 17:41:19 Position Instrument='FDAX 09-07' Account='Uxxxxx' Avg price=0 Quantity=0 Market position=Long Operation=Remove Currency=Euro
          14/08/2007 17:41:19 Order Order='1038173142/Uxxxxx' Name='Stop1' New State=Cancelled Instrument='FDAX 09-07' Action=Sell Limit price=0 Stop price=7457 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error='Order Storniert - Grund: (202)'
          14/08/2007 17:41:18 Order Order='1038173143/Uxxxxx' Name='Target1' New State=PendingChange Instrument='FDAX 09-07' Action=Sell Limit price=7466 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
          14/08/2007 17:41:18 Strategy Closing position strategy
          14/08/2007 17:41:18 ATI AT 'CLOSESTRATEGY;;;;;;;;;;;;DAX_1min_Target.7.5_Stop . 15' processing
          14/08/2007 17:39:46 Order Order='1038173143/Uxxxxx' Name='Target1' New State=Working Instrument='FDAX 09-07' Action=Sell Limit price=7479.5 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
          14/08/2007 17:39:46 Order Order='1038173143/Uxxxxx' Name='Target1' New State=Accepted Instrument='FDAX 09-07' Action=Sell Limit price=7479.5 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
          14/08/2007 17:39:46 Order Order='1038173142/Uxxxxx' Name='Stop1' New State=Accepted Instrument='FDAX 09-07' Action=Sell Limit price=0 Stop price=7457 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
          14/08/2007 17:39:46 Position Instrument='FDAX 09-07' Account='Uxxxxx' Avg price=7472.08 Quantity=1 Market position=Long Operation=Insert Currency=Euro
          14/08/2007 17:39:46 Order Order='f249de8f80e148949da02d7976f41784/Uxxxxx' Name='Target1' New State=PendingSubmit Instrument='FDAX 09-07' Action=Sell Limit price=7479.5 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
          14/08/2007 17:39:46 Order Order='539b22cedbbd4947acea3dee34125dde/Uxxxxx' Name='Stop1' New State=PendingSubmit Instrument='FDAX 09-07' Action=Sell Limit price=0 Stop price=7457 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
          14/08/2007 17:39:45 Execution Execution='FDAX 09-07/0000e9b5.446a2926.01.01' Instrument='FDAX 09-07' Account='Uxxxxx' Exchange=Eurex Price=7472 Quantity=1 Market position=Long Operation=Insert Order='1038173141' Time='14/08/2007 17:39:45'
          14/08/2007 17:39:45 Order Order='1038173141/Uxxxxx' Name='Entry' New State=Filled Instrument='FDAX 09-07' Action=Buy Limit price=7472 Stop price=0 Quantity=1 Type=Limit Filled=1 Fill price=7472 Error=NoError Native error=''
          14/08/2007 17:39:33 Order Order='1038173141/Uxxxxx' Name='Entry' New State=Working Instrument='FDAX 09-07' Action=Buy Limit price=7472 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
          14/08/2007 17:39:33 Order Order='1038173141/Uxxxxx' Name='Entry' New State=Accepted Instrument='FDAX 09-07' Action=Buy Limit price=7472 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
          14/08/2007 17:39:32 Order Order='486621590edf4a4cbe2c22badf96a320/Uxxxxx' Name='Entry' New State=PendingSubmit Instrument='FDAX 09-07' Action=Buy Limit price=7472 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
          14/08/2007 17:39:32 Order Submitting order with strategy
          14/08/2007 17:39:32 ATI AT 'PLACE;Uxxxxx;FDAX 09-07;BUY;1;LIMIT;7472.0;0;DAY;;DAX_1min_Target.7.5_S top. 15;NT_DAX_1min_Target.7.5_Stop.15;DAX_1min_Target. 7.5_Stop. 15' processing

          Comment


            #6
            The problem was that the internal strategy position size was zero. I know this from some of the text in the log file. The problem is that I can't see how the strategy position would be zero.

            If you see this again, please report back.

            Thanks for running the tests.
            RayNinjaTrader Customer Service

            Comment


              #7
              How can I check it? Where in the logfile can I identify, that the strategy position size is zero?

              Torso

              Comment


                #8
                There is nothing specific other than a number of things that I personally can tell from the log file.

                You could tell in NT itself, the "Strategies" tab, position column.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  I am using the following with the intention of disabling a strategy once a specific loss limit has been reached (in dollars) but I am getting coding errors.
                  Thanks.

                  if (Performance.AllTrades.TradesPerformance.Currency. CumProfit <= -800)
                  {
                  CLOSESTRATEGY;;;;;;;;;;;;swingbreak2
                  }


                  Last edited by brucelevy; 05-28-2016, 12:18 PM.

                  Comment


                    #10
                    Hello brucelevy,

                    Thank you for writing in.

                    You will want to use the Disable() method call to disable your strategy: https://ninjatrader.com/support/help...7/?disable.htm

                    Please, let us know if we may be of further assistance.
                    Zachary G.NinjaTrader Customer Service

                    Comment


                      #11
                      Thank you,

                      If the strategy is running on 6 markets does it take the cumulative amount for all instruments enabled under that strategy or is it per instrument? I'd like it to be cumulative for all instruments enabled for that strategy.

                      if(Performance.AllTrades.TradesPerformance.Currenc y.CumProfit >= -800)
                      {
                      Disable();
                      }

                      Comment


                        #12
                        Hello brucelevy,

                        The Performance object holds all trades and trade performance data generated by the strategy for all instruments and is not per instrument.

                        Please, let us know if we may be of further assistance.
                        Zachary G.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks,

                          I am using -1000 for the loss limit, but for some reason I can only enable the first market, and the other markets will not enable.

                          If I take the code out I am able to enable.

                          Is there something wrong with the code below? Thanks.

                          if (Performance.AllTrades.TradesPerformance.Currency. CumProfit <= lossLimit)
                          {
                          Disable();
                          }
                          Last edited by brucelevy; 05-30-2016, 05:41 PM.

                          Comment


                            #14
                            Hello brucelevy,

                            Please remember that your strategy is going to evaluate historically as well; the condition specified can very well be true, which is a reason why your strategy is immediately disabling.

                            I would suggest adding a print before Disable() to see if your if condition is becoming true.

                            Code:
                            if (Performance.AllTrades.TradesPerformance.Currency.CumProfit <= lossLimit)
                            {
                                 Print("Disabling strategy.");
                                 Disable();
                            }
                            To prevent your strategy from running historically, you'll want to check for Historical. If this is true, return. Place this before all other OnBarUpdate() logic.

                            Code:
                            if (Historical)
                                 return;
                            For more information about Historical, please take a look at this help guide link: https://ninjatrader.com/support/help...historical.htm

                            Please, let us know if we may be of further assistance.
                            Zachary G.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Stanfillirenfro, Yesterday, 09:19 AM
                            7 responses
                            51 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by TraderCro, 04-12-2024, 11:36 AM
                            4 responses
                            69 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Mindset, Yesterday, 02:04 AM
                            1 response
                            15 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by agclub, 04-21-2024, 08:57 PM
                            4 responses
                            18 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by Irukandji, Today, 04:58 AM
                            0 responses
                            6 views
                            0 likes
                            Last Post Irukandji  
                            Working...
                            X