Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT7 - ExitOnClose, Friday Only

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

    NT7 - ExitOnClose, Friday Only

    I am attempting to build a NT7 strategy which would stay active all week, Sunday thru Friday and Exit on close on Friday only. I have tested the following script on SIM account. It seems to keep the position open thru the week but DOES NOT close it on Friday as required. Any help would be much appreciated. Thanks!!


    protected override void Initialize()
    {
    ExitOnClose = true;
    ExitOnCloseSeconds = 30;
    }

    protected override void OnBarUpdate()
    {
    if (Time[0].DayOfWeek == DayOfWeek.Friday)
    ExitOnClose = true;
    else
    ExitOnClose = false;
    }

    #2
    Hello SamIam,

    The help guide specifically states ExitOnClose must be set in Initialize().
    https://ninjatrader.com/support/help...xitonclose.htm

    I'm not certain if changing this in OnBarUpdate will lead to unexpected results.

    I propose two alternatives.

    Either use a week long session in a session template that spans from sunday to friday.
    https://ninjatrader.com/support/help...on_manager.htm

    Or just code the exit in the script.
    if (Time[0].DayOfWeek == DayOfWeek.Friday && ToTime(Time[0]) >= 45930) && Position.MarketPosition == MarketPosition.Long)
    ExitLong();
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you ChelseaB! I will test coding the exit in script recommendation.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      557 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 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
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X