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 rocketman7, Today, 02:12 AM
                    5 responses
                    22 views
                    0 likes
                    Last Post rocketman7  
                    Started by trilliantrader, 04-18-2024, 08:16 AM
                    7 responses
                    28 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by samish18, 04-17-2024, 08:57 AM
                    17 responses
                    66 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Started by briansaul, Today, 05:31 AM
                    1 response
                    15 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by PaulMohn, Today, 03:49 AM
                    1 response
                    12 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Working...
                    X