Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What happens when "Flatten Everything" is pressed?

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

    What happens when "Flatten Everything" is pressed?

    If my strategy runs and then I use the function "Flatten Everything" it will generate some exit order.

    So my questions are this:

    1. What will be the name of the exit order? will it have the same custom name that I used to enter the position?

    2. Will the strategy enter the function OnExecutionUpdate() ?

    The reason I ask the above is that my intention is to intercept this exit order and write it to a file. Currently, I intercept normal strategy entry and exit orders inside the OnExecutionUpdate().

    Thank you for your wonderful help,
    as always

    #2
    I am sure NinjaTrader support guys will tell you the answers, but in order to see those yourself, you can always download several days of Market Replay data and turn on Playback to see everything in action.

    Comment


      #3
      UltraNIX , That's not so helpful, I have to know exactly what the strategy is doing...

      Comment


        #4
        Ninjatrader support?

        Comment


          #5
          Hello zoharcho,

          For a position opened by a NinjaScript Strategy this will be closed with an order named 'Close'.

          This will also disable any running strategies and will not run OnOrderUpdate() or OnExecutionUpdate().

          To capture these orders, do this from the Account.ExecutionUpdate event using the Addon approach.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_ChelseaB View Post
            Hello zoharcho,

            For a position opened by a NinjaScript Strategy this will be closed with an order named 'Close'.

            This will also disable any running strategies and will not run OnOrderUpdate() or OnExecutionUpdate().

            To capture these orders, do this from the Account.ExecutionUpdate event using the Addon approach.
            https://ninjatrader.com/support/help...tionupdate.htm
            Hello ChelseaB,

            After you referenced me to the add-ons section, I did some digging in the add-on documentation, can you make the following subjects clearer?

            1. Add-on is a code that runs outside (independent) the strategy operation?

            2. Where do I enter its code (in the "strategy" code file? or new other code file type? Is there an example add-on file that I can learn from?

            3. If what I understand is correct, the button "Flatten Everything" is basically an add-on that does the following actions:
            a. close all strategies.
            b. generate "close" orders to any orders that were generated from NT.

            Can you confirm? Does it happen in that exact order?

            4. I can create my own custom "Flatten Everything" button which is also an add-on that does exactly what I want, correct?

            Thank you!
            Feeling like I am about to level UP my NT coding skills

            Comment


              #7
              Hello zoharcho,

              Yes, the Addon approach is outside of a NinjaScript Strategy.

              The code could be entered into an indicator or a separate Addon window.

              Closing a position using the Close button or Flatten Everything will disable all strategies running on the account and instrument automatically. And yes, this will cause NinjaTrader to submit a 'Close' order.

              To flatten a position, use Account.Flatten() with an array of the instruments you want to flatten.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Ok, thanks. I will check it out.

                Comment


                  #9
                  NinjaTrader_ChelseaB I could not get my collection properly initialized instrumentsToClose and I also would not neccessarily close everything but I have been working with addon approach inside a strategy.

                  Can you help me complete the //private Collection(Cbi.Instrument) instrumentsToClose;

                  zoharcho here is close code per strategy ( I just wrote it IT IS NOT WORKING) But perhaps Chelsea can assist with the variable set up.

                  I will get it working as I have a runaway script condition that I need to resolve

                  AlertFlatten.zip
                  Attached Files
                  Last edited by BartMan; 06-17-2022, 09:08 AM.

                  Comment


                    #10
                    Hello BartMan,

                    Use <> and not () to specify a type. This is not a method call.

                    private Collection<Cbi.Instrument> instrumentsToClose; <-- correct

                    instead of

                    private Collection(Cbi.Instrument) instrumentsToClose; <-- incorrect
                    Last edited by NinjaTrader_ChelseaB; 06-20-2022, 07:22 AM.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      thanks Chelsea

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by NullPointStrategies, Yesterday, 05:17 AM
                      0 responses
                      53 views
                      0 likes
                      Last Post NullPointStrategies  
                      Started by argusthome, 03-08-2026, 10:06 AM
                      0 responses
                      130 views
                      0 likes
                      Last Post argusthome  
                      Started by NabilKhattabi, 03-06-2026, 11:18 AM
                      0 responses
                      70 views
                      0 likes
                      Last Post NabilKhattabi  
                      Started by Deep42, 03-06-2026, 12:28 AM
                      0 responses
                      44 views
                      0 likes
                      Last Post Deep42
                      by Deep42
                       
                      Started by TheRealMorford, 03-05-2026, 06:15 PM
                      0 responses
                      49 views
                      0 likes
                      Last Post TheRealMorford  
                      Working...
                      X