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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      51 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      142 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      275 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X