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 GussJ, 03-04-2020, 03:11 PM
              16 responses
              3,281 views
              0 likes
              Last Post Leafcutter  
              Started by WHICKED, Today, 12:45 PM
              2 responses
              19 views
              0 likes
              Last Post WHICKED
              by WHICKED
               
              Started by Tim-c, Today, 02:10 PM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by Taddypole, Today, 02:47 PM
              0 responses
              5 views
              0 likes
              Last Post Taddypole  
              Started by chbruno, 04-24-2024, 04:10 PM
              4 responses
              53 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Working...
              X