Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

exit on friday or last day of week

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

    exit on friday or last day of week

    Is there a simple way to that I can code my strategy to exit on Fridays?

    I know about the normal "exit on close" that exits on every end of day. I am trading currencies - and would like to keep open trades open except on Fridays.

    #2
    Hi verge, you can for example work with this snippet below -

    Code:
    if (Time[0].DayOfWeek == DayOfWeek.Friday)
    			{
    				ExitLong();
    				ExitShort();
    			}

    Comment


      #3
      Thank you but

      Originally posted by NinjaTrader_Bertrand View Post
      Hi verge, you can for example work with this snippet below -

      Code:
      if (Time[0].DayOfWeek == DayOfWeek.Friday)
      			{
      				ExitLong();
      				ExitShort();
      			}
      Thank you Bertrand but I may have not been descriptive enough. I think the code will result in my trades being exited at the beginning of Friday - while I want it to exit at the end of the session of Friday. I assume I have to include time as well - in addition to day of week? If correct please provide a snippet of that includes time please

      Comment


        #4
        You could simply add your time to exit then to this condition -

        Code:
        	if (Time[0].DayOfWeek == DayOfWeek.Friday && ToTime(Time[0]) >= 120000)
        			{
        				ExitLong();
        				ExitShort();
        			}
        This would fire an ExitLong / ExitShort on Friday and local time being equal or greater then 1200, you can adapt to your needs.

        Comment


          #5
          thank you

          thank you Bertrand

          Comment


            #6
            Hi

            i'm reading this really interesting answer from Bertrand... i put this code on my script with a hour of 180000... so my trade close Friday at 18:00 but (sorry there is always a but) if there is a signal after Friday 18:00... my script take a position and close it on the next bar (i'm running my script in 15minutes)

            so my question is: how to say

            if (Time[0].DayOfWeek == DayOfWeek.Friday && ToTime(Time[0]) >= 180000)
            {
            ExitLong();
            ExitShort();
            AND DO NOT TAKE ANY POSITION BETWEEN FRIDAY 18:00 AND 22:00 (the real close of the market)
            }

            Can you help ?
            Thx

            Comment


              #7
              Thomas, you would need to incorporate the red part into your trading conditions directly, so you can set the time filter as needed to not submit any order on the bar before the strategy close.

              Comment


                #8
                Hi
                do you have a code example

                because i put

                if (Time[0].DayOfWeek != DayOfWeek.Friday && ToTime(Time[0]) < 180000)

                enterlong...

                and the problem is than it doesn't not take position every day after 18:00... i want than the strategy doesn't take a position after 18:00 but only on friday, not every day...

                how to say friday after 18:00 ?

                Comment


                  #9
                  You can try for example something like this -

                  canTradeMT = (Time[0].DayOfWeek != DayOfWeek.Friday);
                  canTradeFR = (Time[0].DayOfWeek == DayOfWeek.Friday && ToTime(Time[0]) < 180000);

                  canTrade = (canTradeMT || canTradeFR);

                  Then simply check for canTrade to be true in your entry rules.

                  Comment


                    #10
                    Hi

                    it is working on backtest but not in realtime...

                    my computer is in French, may be i have to turn it in English ?

                    Can you help ?

                    Comment


                      #11
                      Thomas,

                      Please ensure that if you are attaching the strategy to a chart, Enabled is set to True in the strategy properties. Are you performing this step?
                      Adam P.NinjaTrader Customer Service

                      Comment


                        #12
                        yes i performed this step.

                        the thing is that in real it does not work... and then when i made the backtest it is working...

                        Comment


                          #13
                          Thomas,

                          Could you perhaps send this strategy to me? You can either attach it here or send to [email protected] with attn : adam in the message.
                          Adam P.NinjaTrader Customer Service

                          Comment


                            #14
                            Hi,

                            if (Time[0].DayOfWeek == DayOfWeek.Friday)
                            {
                            // ExitLong();
                            // ExitShort();
                            ExitOnClose = true;
                            }

                            will it close position at the closing of Friday?

                            Thanks

                            Comment


                              #15
                              test , working

                              Comment

                              Latest Posts

                              Collapse

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