Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Preventing Entry+Exit Orders at same time

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

    Preventing Entry+Exit Orders at same time

    My strategy is set up such that it is conceivable an entry and an exit can occur on the same bar, cancelling each other out and incurring transaction costs.

    Is there some logic I can add to the strategy to prevent this from happening? I would like the strategy to identify if an entry order will be placed simultaneously with an exit order, and to ignore both orders.

    I currently am using the Strategy Builder. Any input is appreciated though.

    #2
    Hello liquid150,

    Thanks for opening the thread.

    Yes, you can use additional logic to outline when your strategy should specifically enter or exit. I have created a demonstration showing how you can use bools to make you entry and exit conditions more explicit.

    Demo - https://www.screencast.com/t/wrRtdOkq

    Additional tips on using the Strategy Builder can be seen in the Strategy Builder 301 webinar. I will provide a link to a publicly available recorded version of this webinar.

    Strategy Builder 301 - https://www.youtube.com/watch?v=HCyt90GAs9k

    Please let me know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jim View Post
      Hello liquid150,

      Thanks for opening the thread.

      Yes, you can use additional logic to outline when your strategy should specifically enter or exit. I have created a demonstration showing how you can use bools to make you entry and exit conditions more explicit.

      Demo - https://www.screencast.com/t/wrRtdOkq

      Additional tips on using the Strategy Builder can be seen in the Strategy Builder 301 webinar. I will provide a link to a publicly available recorded version of this webinar.

      Strategy Builder 301 - https://www.youtube.com/watch?v=HCyt90GAs9k

      Please let me know if you have any additional questions.
      Ah, thanks Jim.

      I was hoping there was some easier way to do this by checking for order submittals, but this will (probably) work.

      Comment


        #4
        Hello liquid150,

        You may also consider checking BarsSinceEntryExecution before submitting your exit order. This method is also available in the Strategy Builder.

        BarsSinceEntryExecution - https://ninjatrader.com/support/help...yexecution.htm

        If you have any questions on this method, please don't hesitate to ask.
        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Hello liquid150,

          You may also consider checking BarsSinceEntryExecution before submitting your exit order. This method is also available in the Strategy Builder.

          BarsSinceEntryExecution - https://ninjatrader.com/support/help...yexecution.htm

          If you have any questions on this method, please don't hesitate to ask.
          Sure, quick question on this method. If I set BarsSinceEntryExecution to zero, will this capture an entry execution and change a boolean parameter to "false" before the exit order is executed?

          I am trying to figure out if there is an order of operations the software follows which I can exploit...

          Comment


            #6
            Hello liquid150,

            BarsSinceEntryExecution is a method and not a property. It will return a value when called and you cannot set its value. This return value is an integer, not a bool.

            From the help guide:
            Definition
            Returns the number of bars that have elapsed since the last specified entry.

            Method Return Value
            An int value that represents a number of bars. A value of -1 will be returned if a previous entry does not exist.
            In other words, this will tell you how many bars have passed since an entry method has been executed (filled.)

            I suggest to print the return value of this method in a simple strategy to visualize how it works. You can place the print in the actions section of an empty condition to see it print with each bar update. Prints can be observed in the NinjaScript output window. (Control Center > New > NinjaScript Output)

            If you have any questions on the results you are seeing, please don't hesitate to write back with the prints you are receiving.
            JimNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Jim View Post
              Hello liquid150,

              BarsSinceEntryExecution is a method and not a property. It will return a value when called and you cannot set its value. This return value is an integer, not a bool.

              From the help guide:

              In other words, this will tell you how many bars have passed since an entry method has been executed (filled.)

              I suggest to print the return value of this method in a simple strategy to visualize how it works. You can place the print in the actions section of an empty condition to see it print with each bar update. Prints can be observed in the NinjaScript output window. (Control Center > New > NinjaScript Output)

              If you have any questions on the results you are seeing, please don't hesitate to write back with the prints you are receiving.
              My apologies for my unclear language. I intend to be asking the following:

              If I call BarsSinceEntryExecution, and create a Boolean variable "AllowExit," and define BarsSinceEntryExecution = 0 call o be AllowExit = False, will this work?

              I suspect not, but it's much easier than isolating the exact conditions in the strategy which need be filtered out.

              Comment


                #8
                Hello liquid150,

                When BarsSinceEntryExecution() == 0, this means an entry order has just been filled. You would not see this on the same bar of an order submission. I would suggest to set AllowExit to true when BarsSinceEntryExecution() > SomeNumberOfBars.

                I would still suggest to set up tests to observe the functionality of BarsSinceEntryExecution so you can use it properly in your strategy.

                I have a created a video demonstrating such a test.

                Demo: https://www.screencast.com/t/sShhayIXFli

                Please let me know if I may be of further assistance.
                JimNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Jim View Post
                  Hello liquid150,

                  When BarsSinceEntryExecution() == 0, this means an entry order has just been filled. You would not see this on the same bar of an order submission. I would suggest to set AllowExit to true when BarsSinceEntryExecution() > SomeNumberOfBars.

                  I would still suggest to set up tests to observe the functionality of BarsSinceEntryExecution so you can use it properly in your strategy.

                  I have a created a video demonstrating such a test.

                  Demo: https://www.screencast.com/t/sShhayIXFli

                  Please let me know if I may be of further assistance.
                  Thanks, anyway Jim. I had a feeling it had to be filled for it to register. I will isolate the condition which should switch a pair of booleans as you previously suggested. I am already using a BarsSinceEntry and BarsSinceExit condition in other places in the strategy, but thank you for your time.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Renejm, Today, 06:17 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post Renejm
                  by Renejm
                   
                  Started by kazisl, Yesterday, 06:41 PM
                  2 responses
                  10 views
                  0 likes
                  Last Post NinjaTrader_PaulH  
                  Started by impactX, 05-04-2021, 01:07 AM
                  1 response
                  7 views
                  0 likes
                  Last Post Lancer
                  by Lancer
                   
                  Started by op1031, Yesterday, 05:51 PM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_PaulH  
                  Started by aaadetos, 05-04-2021, 09:28 AM
                  3 responses
                  13 views
                  0 likes
                  Last Post NinjaTrader_Heath  
                  Working...
                  X