Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitOnClose at EOD data backtest

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

    ExitOnClose at EOD data backtest

    Hi guys,

    how can I force NT to close position on Close instead of on Open. I tried to put in "ExitOnClose = true", even "false", but system exits on Open anyway.

    Does that work at End of Day data and during backtest?

    thanks

    sniper29a

    #2
    sniper29a,

    Unfortunately this is not possible in backtesting. Reason is as follows: When you are backtesting you get your signals from the OHLC data of the bars. On your signal bar you already have the Close value. Since you have the close value already of that bar we are no longer able to trade on that bar. Your trade signals were only evaluated to true at the exact moment of having the close value. The next possible trade time is now the open of the next bar and that is what you are seeing. There is no way around this.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      ok, thanks for reply. I always want what is impossible )

      Comment


        #4
        Obvious design issue!
        "Close" always occurs after "Open", therefore proper programming logic should accommodate this. I've used other trading software, such as Tradestation, and it has no problem understanding this basic fact. Perhaps a fix in a later version of NT?

        Comment


          #5
          chartman,

          I do not know why you think it is a design flaw. NinjaTrader fill models take the most conservative approach possible. If you have the close price of a bar there is absolutely no way you can trade on that bar without cheating. The issue is not about Close being after Open. You evaluate your conditions based on one moment in time. All of your indicators etc were calcualted with OHLC. If you have Close then Open already passed. If Open already passsed no way you can trade at open. If Close already exists no way you can trade on that bar therefore next tradeable location is the Open of the next bar.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Not cheating - realistic!
            I'm presently working on a strategy that evaluates several instruments at the close of [1] day back, executes a trade at the open of the present day (without "knowing" the close), and closes the trade at the end of the session. Of course there is slippage - you cannot execute exactly at the open or close, but you account for that.
            Because NT doesn't consider that the close occurs after the open of a specific day, I cannot use daily data to test this stragegy.
            As I stated in my previous post, I used Tradestation a few years ago to backtest a similar strategy with no problems.

            Comment


              #7
              chartman,

              I do not see why you find this an issue then. In backtesting just run your evaluations as Close[0]. That will determine your trades and then it will be submitted at the Open of the new bar that is just about to form. It is very much so to be cheating if you try to trade on a bar that you already know the Close price of.

              I do not understand what you mean by "NT doesn't consider that the close occurs after the open of a specific day". NT is tick driven. When a tick coming in informs NT it is a new day then it knows a close occurred.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                That's what I am attempting to do, however ExitOnClose() does not execute the exit trade.

                Comment


                  #9
                  Are you backtesting or are you real-time?
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Backtesting.

                    Comment


                      #11
                      Then that is the problem right there. ExitOnClose uses intrabar logic. It is tied to the ExitOnCloseSeconds parameter. By default it exits 30 seconds before session end. In backtesting, with daily bars, you have no information on what that price was 30 seconds before market close.

                      You're asking for intrabar granularity backtesting. If that is what you want to do then you will want to look at this reference sample: http://www.ninjatrader-support2.com/...ead.php?t=6652
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        I don't know why is such a problem to exit on Close in backtest??? It seems to me same whether you exit on Open, as NT does, or you want exir on Close, as I want and intend. But, NT always exit on Open. It is not cheating, but rule of system that says "exit on close".

                        I don't know, whether my question has been understood at firstime.

                        Other SW are able to do it. I appreciate your work guys, despite free SW. It might be new function incorporated in your SW.

                        Comment


                          #13
                          Hi sniper29a,

                          I think Josh's post sums it up well - you cannot generate a true EOD exit from daily charts, if you want to trade a daily chart and need to simulate the EOD exit as close as you can, you need to recode your strategy to use a second, finer intraday datastream - a reference sample how to implement this can be found here - http://www.ninjatrader-support2.com/...ead.php?t=6652

                          Comment


                            #14
                            it is just backtest. so why not Close - half point and you have exit. is it so difficult? you don't catch exact Open either. Besides, we have e-markets. they are 24/7 almost ;-)

                            Or time exit, if you disagree with exit on Close concept. 5min before close. if you backtest, you don't bother about details.

                            Did you ever trade guys?

                            Comment


                              #15
                              sniper29a,

                              As explained, when you have the close price of that bar already you cannot generate any signals for that bar. With the close price that is the end of the bar, there is no "Exit on Close". Any price you try to generate to fill is bogus. "Exit on Close" is never an actual close at the exit. It is a close 30 seconds before the exit. How do you know what the price was 30 seconds before the close on a daily bar? You do not and as such no trade can ever be made. Any price you try to fill at is a cheating price.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              574 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              333 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              553 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              551 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X