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

How to exit trades at set day of week and time

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

    #16
    demo166130.

    What session template are you using?

    Does 9:45 fall within the trading hours for that instrument?

    Josh G.NinjaTrader Customer Service

    Comment


      #17
      It is yes. Is the problem with this command not that it will exit open trades, but that it will still continue to enter them even during the time periood we set because it's only instructing open trades to close, not trades not to open? Hope you catch my drift

      Comment


        #18
        Unsure what you mean by session template. I don't think I've changed anything template wise. 15 minute time bars on a regular AUD/USD CFD chart

        Comment


          #19
          demo166130,

          Sounds like you should create another time filter for your entries so you can limit when they occur.
          Josh G.NinjaTrader Customer Service

          Comment


            #20
            Hello!
            Can you please explaine, how can i set for a strategy, in Strategy Builder, period of time during the week (for example, start monday at 01:00 and finish friday at 22:00), when strategy could make trades? Friday at 22:00 it should close all open positions and stop till monday!
            Can't understand, how could it be done with time filters

            Comment


              #21
              Hello vvu1980,

              Thank you for your post.

              Unfortunately, since the market is closed on Friday at 10:00PM and no trading occurs, you would not be able to close all positions. All positions would need to be closed during active market hours.

              Something you could do is have your strategy place trades between Monday at 1:00AM - Friday at 12:00PM. Then, close all positions after Friday at 12:00PM.

              To do this you would need to first need to create a bool variable (initially set to false). Then you would need to create a condition in Set 1 with a time filter that checks if the day of the week is Monday and if the Time is greater than or equal to 1:00 AM. Then, we would set our bool to true in the actions section.

              In Set 2 we would create a condition that checks if the bool is true, if Position.MarketPosition == MarketPosition.Flat, if the Close[0] is greater than the Open[0], and call EnterLong to enter a long position.

              In Set 3 we would create another time filter that checks if the day of the week is Friday and if the time is greater than 12:00PM. Then, we would set our bool to false in the actions section.

              In Set 4 we check if the bool is false and if Postion.MarketPosition != MarketPosition.Flat followed by calling ExitLong.

              Please see the attached example strategy that demonstrates how this could be accomplished.

              Also, please open a new thread for inquiries in the future instead of bumping old forum threads. It is possible that we may miss your inquiry if you reply to an old forum thread.

              Let us know if we may assist further.
              Attached Files
              Brandon H.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by DJ888, 04-16-2024, 06:09 PM
              4 responses
              12 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by terofs, Today, 04:18 PM
              0 responses
              8 views
              0 likes
              Last Post terofs
              by terofs
               
              Started by nandhumca, Today, 03:41 PM
              0 responses
              6 views
              0 likes
              Last Post nandhumca  
              Started by The_Sec, Today, 03:37 PM
              0 responses
              3 views
              0 likes
              Last Post The_Sec
              by The_Sec
               
              Started by GwFutures1988, Today, 02:48 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Working...
              X