Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do prevent selling of our position on the same day that it was opened?

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

    How do prevent selling of our position on the same day that it was opened?

    I want my automatic trading strategy to not close a position on the same day that it was opened. How do I do this?

    Thanks

    Tom

    #2
    Tom, for this you would need to set ExitOnClose in the UI to false when running or backtesting your strategy -



    Comment


      #3
      ExitOnClose "Indicates if the strategy will cancel all strategy generated orders and close all open strategy positions at the close of the session."

      This is not what I want to do. I only want the open order to execute no more than once per day and for sell order to not execute on the same day the open order was executed. Also I want to control this programatically.

      Comment


        #4
        Tom, thanks for clarifying - you would then need to control this via a boolean flag included in your trade entry conditions that you reset each day to allow for new trades to be taken.

        Comment


          #5
          Look in the Help Guide for 'IExecution', there is a 'DateTime' property that you can use in your boolean trade logic conditional statements.

          Comment


            #6
            Thanks looks like that will work.

            Looks like you get the iExecution variable passed in on OnExecution. Can I save that to a global variable at that time and reference it later?

            Another related question. Is there a new instance of the strategy running for each equity it is monitoring? In other words, if I save iExecution to a global variable, will it affect any other equities I'll be monitoring with the same strategy?

            thanks

            Comment


              #7
              Tom, yes you could save values returned to a custom variable.

              Correct, this would only refer to the individual strategy instance, as NinjaScript strategies do not cross communicate.

              Comment

              Latest Posts

              Collapse

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