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

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 Salahinho99, Today, 04:13 AM
          0 responses
          11 views
          0 likes
          Last Post Salahinho99  
          Started by junkone, 04-28-2024, 02:19 PM
          8 responses
          92 views
          1 like
          Last Post brucerobinson  
          Started by mkouitra, 10-23-2021, 04:40 PM
          17 responses
          1,968 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by Vietanhnguyen2hotmailcom, 05-03-2024, 10:29 AM
          4 responses
          31 views
          0 likes
          Last Post Vietanhnguyen2hotmailcom  
          Started by PhillT, 04-19-2024, 02:16 PM
          4 responses
          39 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Working...
          X