Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

The "Exit on close" time

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

    The "Exit on close" time

    In NT, Is there a setting for "Exit on close" for each commodity. I was experiementing with backtesting and the times set happened to be 12 to 12. And i saw that the "exit on close" trades were being placed at 12, instead of the market closing time. Do you set the closing time for each commodity in NT? How?

    #2
    On chart properties there are session open and close times you can change
    Last edited by roonius; 01-08-2009, 09:00 PM.

    Comment


      #3
      That limits the chart also to the times you set. Is there any way to set the "exit on close" (which is absolutely necessary for auto trade) times set to the exchange hours but still have the chart for the extended hours as well.

      Comment


        #4
        Hi ju1234,

        This cannot be set individually for each symbol.

        Please look into this link http://www.ninjatrader-support.com/H...itOnClose.html

        and use the 'ExitOnClose = True' command in your Initialize section, this will allow to use the session endling times then to flatten your positions.

        Please also review this link here - http://www.ninjatrader-support2.com/...ead.php?t=3226
        BertrandNinjaTrader Customer Service

        Comment


          #5
          The initialize does not give a choice of setting the times. the times are from the session time which limits the chart to those hours as well. So, can it be incorporated in the strategy to "close all open positions at xx time"? How? thanks.

          Comment


            #6
            Hi ju1234,

            Have you reviewed my second link? It details how TimeFilters can be used to limit trading hours of a strategy - http://www.ninjatrader-support2.com/...ead.php?t=3226

            You could add this snippet to your strategy to close out positions at 15:59 for example -

            Code:
            [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][SIZE=2][SIZE=2] ((ToTime(Time[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]]) >= [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]155900[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]))
            {
            ExitLong();
            ExitShort();
            }
            [/SIZE][/SIZE]


            You can also use one chart for your strategy and use another for your charting (this would then include 24hr data if you like)
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Hi guys,

              Seemingly I am not the only one with ExitOnClose-related problems. My problem;

              I want to close all open positions 60 seconds before the end of trading. I have the following settings:

              ExitOnClose = true;
              ExitOnCloseSeconds = 60;

              I am paper trading 6E (Sim account). My computer is in the Finnish time (= CST + 8 hours) so when trading stops at 16 CST on Globex, it's midnight in Finland.

              Everything seems to work fine when backtesting ('Exit on closes' plotted on charts), but when I run my strategies with real-time data, open positions remain open after midnight. What's the problem and what's the recommended way of fixing it? Can I use 'ExitOnClose' (how?) or should I resort to 'ToTime(Time[0]) >= 235900'? Cheers...

              Comment


                #8
                Hi jp_kettunen, first please try to sync your PC clock up with the 'Internet Time' function in Windows.

                Next, please add TraceOrders = true to your strategy and see if the order is being generated properly.

                You can also use the code I posted below to exit at your desired time setting.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Bertrand View Post
                  Hi ju1234,

                  Have you reviewed my second link? It details how TimeFilters can be used to limit trading hours of a strategy - http://www.ninjatrader-support2.com/...ead.php?t=3226

                  You could add this snippet to your strategy to close out positions at 15:59 for example -

                  Code:
                  [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][SIZE=2][SIZE=2] ((ToTime(Time[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]]) >= [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]155900[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]))
                  {
                  ExitLong();
                  ExitShort();
                  }
                  [/SIZE][/SIZE]


                  You can also use one chart for your strategy and use another for your charting (this would then include 24hr data if you like)
                  thanks for this

                  Comment


                    #10
                    Thanks,
                    My PC clock is in time - cannot figure out how sync with Internet time could help. But that 'ToTime' thing appears to work as expected, so I'll use it.

                    Comment


                      #11
                      Well it's important the PC clock is very accurate (down to seconds) as the order has to be send on time to avoid being rejected by the exchange. If the other code works well for you, great!
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        Exit On Close problem.

                        In my strategy I have session start time 0:02 and end 0:00
                        I am using multi time frame strategy. And its closes my session 8:02pm.
                        I don't have any ExitonCLose settings.
                        I want to close end of session. But it closes ealier.
                        Thanks

                        I also tried to use your example. ExitOnClose=false;
                        and then add manual exit, still its exits 8:02 pm.
                        Last edited by kekkis; 03-12-2009, 12:53 PM. Reason: Adds and Testing

                        Comment


                          #13
                          Hi kekkis, when exactly does it close positions out?

                          Did you follow the suggestions to sync your PC clock from this thread?
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_Bertrand View Post
                            Hi kekkis, when exactly does it close positions out?

                            Did you follow the suggestions to sync your PC clock from this thread?

                            Yes , it's sync. It's happend real time and in Strategy Analyser.

                            Comment


                              #15
                              kekkis,

                              I guess I do not understand what you have programmed to tell it to exit. Did you use a time filter? Please provide the code. Thank you.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by claxxical, 05-30-2017, 12:30 PM
                              37 responses
                              4,452 views
                              0 likes
                              Last Post Padan
                              by Padan
                               
                              Started by SugarDefwebsite, Today, 02:18 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post SugarDefwebsite  
                              Started by usglucofreeze, Today, 01:19 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post usglucofreeze  
                              Started by f.saeidi, Today, 01:12 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post f.saeidi  
                              Started by NinjaTrader_ChelseaB, 03-14-2017, 10:17 AM
                              227 responses
                              34,319 views
                              7 likes
                              Last Post rare312
                              by rare312
                               
                              Working...
                              X