Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

FLATTENEVERYTHING and CANCELALLORDERS

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

    FLATTENEVERYTHING and CANCELALLORDERS

    Time to flatten
    Sets the time (local PC time) where a position will be flattened and working orders cancelled.


    I see on the Misc tab under Options you can flatten all positions and cancel working orders.

    But how would you FLATTENEVERYTHING and CANCELALLORDERS in a strategy?

    thanks

    #2
    Hello kenb2004,
    You can use the below unsupported code to flatten everything.

    Code:
    NinjaTrader.Gui.SuperDom.SuperDom.FlattenEverything()
    this.CancelAllOrder(true, true); will cancel all order for that specific strategy.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      So if I put both of these code snippets in a time filter it would do what I asked, FLATTENEVERYTHING and CANCELALLORDERS in a strategy?

      thanks

      Comment


        #4
        Hello kenb2004,
        NinjaTrader.Gui.SuperDom.SuperDom.FlattenEverythin g() will close all open positions and will cancel all order in every account.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Code:
          [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnBarUpdate(){ 
          [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New]if (!TradeTime)[/FONT]
          [FONT=Courier New]NinjaTrader.Gui.SuperDom.SuperDom.FlattenEverything() ;[/FONT]
          }
          So would something like this work? Assuming TradeTime is a bool representing a time filter.

          Thanks

          Comment


            #6
            Hello kenb2004,
            Yes, it should. This is however unsupported and hence would request you to test it further before going live.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              OK... is there a better, Supported method for doing this?

              Comment


                #8
                Just as a side note, NinjaTrader.Gui.SuperDom.SuperDom.FlattenEverythin g() also disables the strategy.

                I think the supported method would be to keep track of all of your positions and close them if they're open at the time of your TradeTime bool. But as long as you're ok with your strategy being disabled afterward, I know several people here have used NinjaTrader.Gui.SuperDom.SuperDom.FlattenEverythin g(), and I haven't read any complaints about it.
                Last edited by Radical; 08-01-2012, 09:38 AM.

                Comment


                  #9
                  OK, I tried adding that code and there were no trades at all. All it did was flatteneverything before tradetime and then stayed flatten forever.

                  No that won't work if it shuts the strategy down. Is there not a code to just FLATTENEVERYTHING and CANCELALLORDERS without stopping the strategy?

                  Comment


                    #10
                    Hello kenb2004,
                    Unfortunately as Radical noted it will disable the strategy. There are no supported codes to do what you are trying to do.
                    JoydeepNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

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