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 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 -



    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        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.
              BertrandNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by bortz, 11-06-2023, 08:04 AM
              47 responses
              1,602 views
              0 likes
              Last Post aligator  
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              8 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              4 views
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              12 views
              0 likes
              Last Post Javierw.ok  
              Working...
              X