Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitOnClose

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

    ExitOnClose

    I have my strategy coded to only trade during market hours of 9:30 AM to 4:15 PM est. I stop entering new trades at 3:45 PM est but will allow any open positions to remain open until either my planned exit or at 4:00 whichever happens first. That last trade of the day also resets all my variables to be ready for the next day. The resetting of my variables works very well except in the following case. Or at least this is the only case so far. Nov 28 was the day after Thanksgiving and the market closed at 1:15 PM est I believer. At least that's the last bar on my chart. The trade was closed but unfortunately my variables weren't reset causing problems on the next trading day where no trades were taken.

    So, how can I handle these unexpected or abnormal market closings and be able to exit the open trades and reset my variables.

    Thanks,
    Mike

    #2
    You essentially can't. You need to either wait till the first tick of the new day and check for changes in dates to determine this or you just have to program into your logic the abnormal closing times into your strategy.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Josh...I kind of figured that. There's a lot of "abnormal" market hours out there. I think the first tick of the day will do the trick for me.

      Thanks,
      Mike

      Comment


        #4
        Mike,

        I have some of the same time criteria so what I have done is create Param Variable called lastEntryTime and use ToTime(Time[0]) <= 154000 as part of the entry signal condition so no entries are made after 3:40 PM. I also use this to prevent entries prior to big reports, FOMC for example. IF I know that FOMC is out at 2:15 PM I just change the variable to 140000 so no entries after 2:00 PM. You can also use the same logic to exit trades at certain time but I just use exit on close.

        Comment


          #5
          Thanks for the reply...I do the same in my strategies and even in indicators that display objects when certain criteria are met. So, I've been doing that sort of thing for quite a while. That works very well when I am sitting at my computer in a live market where I can manage the exceptions. However, in backtesting a strategy using the Strategy Analyzer that poor little thing just doesn't know all the exceptions so I have to account for them in my strategy. So, in this case what I did was just as Josh suggested. I reset my variables on the first tick of the day. That takes care of everything that occurs when an unplanned end of day occurs.

          Thanks again,
          Mike

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          580 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          335 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          102 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          552 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X