Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to close position (say 10 mins) before a scheduled session close?

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

    How to close position (say 10 mins) before a scheduled session close?

    Hello,

    How can I programmatically determine the exact time (say 10 mins before a scheduled session close), so that I may close my positions before at the time?
    Your help is much appreciated.

    Best regards,

    Billy

    #2
    Hello Billy,

    A SessionIterator can be used to get the start and end times of a session.
    https://ninjatrader.com/support/help...oniterator.htm

    Below is a link to an example script PreventEntryAfterExitOnCloseExample_NT8 that uses this.
    https://ninjatrader.com/support/foru...ose#post100666

    You can subtract minutes from a DateTime object in C# with <DateTime>.AddMinutes(-10).
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chelsea!

      Comment


        #4
        Hello Chelsea,

        Just to be sure, during regular trading weekdays, would "end times of a session" using SessionIterator be 3:15pm?

        Billy

        Comment


          #5
          Hello Billy,

          That would depend on the instrument being used and the Trading Hours template.

          You can check the session in the Trading hours window.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Chelsea,

            Yes, I was referring to E-mini S&P 500, because the market would normally take a break at 3:15pm and resume at 3:30pm (except Friday), so I was wondering if "end times of a session" using SessionIterator would show 3:15pm? Thanks.

            Comment


              #7
              Hello billythekid72,

              No, the ES future uses the CME US INDEX FUTURES ETH trading hours which ends at 4:00 PM Central. The 15 minute break is not a session close.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Today, 05:17 AM
              0 responses
              50 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              126 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              69 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              42 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              46 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X