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

Long Entry Filled, Short Signal Occurs

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

    Long Entry Filled, Short Signal Occurs

    Hello,

    What will happen if I am in a Long Position and the strategy sees a Short Signal occurs?

    Will NT ignore the short signal until the Long Position is closed? Or execute the short signal once the long position is closed "if" the short conditions still are true.

    I hope I make sense.

    Thank you

    #2
    Hi simple_goodoboy,

    Edit
    When using the managed approach, NinjaTrader will automatically flip the position from long to short or vice versa.

    A common mistake is to call ExitLong() and EnterShort() the same bar which is guaranteed to cause undesired behavior.

    When calling an entry method in the opposite direction of your position this will cause your position to be reversed. NinjaTrader will automatically submit an order to close your existing position and then enter an order to enter you into the opposite position.

    If you exit and then call an entry method in the same run of OnBarUpdate, the OnPositionUpdate() will not have yet run and NinjaTrader will not have known that your position is closed. This will cause both actions to complete and end up sending 3 orders. The first order is the exit position from your exit method, the second order is to close the position from NinjaTrader automatically reversing your position, the third order is to enter you into the opposite position.

    The result is that either the script will double the quantity when it reverses or it will cause an overfill and stop the script.
    Last edited by NinjaTrader_ChelseaB; 03-07-2017, 08:02 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hi simple_goodoboy,

      NinjaTrader will automatically flip the position from long to short or vice versa.
      Thank you ChelseaB,

      Just to make sure I understand correctly.

      Let's pretend the following strategy

      Buy when 7ema crossabove 20ema
      Sell when 20ema crossbelow 7ema

      Target 40 ticks
      Stop 30 ticks

      Questions:
      1. I am in a long position waiting for 40 ticks profit to occur, and a sell signal occurs, the long position will exit (for a loss or profit), AND then a sell position will be executed by the strategy ?

      2. I am in a short position waiting for 40 ticks profit to occur, and a buy signal occurs, the short position will exit (for a loss or profit), AND then a buy position will be executed by the strategy ?

      Am i correct in my questions below? If so, can you explain the logic behind this please? I guess that make sense to do that, because the strategy is simply executing what it told to do.

      Thanks

      Comment


        #4
        Hello simple_goodoboy,

        Yes your understanding is correct.

        When using the managed approach, if in a long position and a sell entry is called, NinjaTrader will automatically submit a sell order to exit the long position (named Close position) and then submit the sell entry order to enter the new position.

        If in a short position and a buy entry is called, NinjaTrader will automatically submit a buy order to exit the short position (named Close position) and then submit the buy entry order to enter the new position.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello simple_goodoboy,

          When using the managed approach
          Thank you ChelseaB, this makes sense now.

          What is the managed approach mean please?

          Thanks

          Comment


            #6
            Hello simple_goodoboy,

            The managed approach uses EnterLong/EnterShort/ExitLong/ExitShort methods and NinjaTrader will try and manage the position to reduce the amount of code necessary for the script to function, but has rules to prevent unwanted positions.


            The unmanaged approach uses SubmitOrder() to submit all orders entry and exit. All orders and positions must be explicitly managed with code in the script. This gives the developer more control and less chance of violating the Internal order handling rules but requires more code to manage the orders and positions,
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello simple_goodoboy,

              The managed approach uses EnterLong/EnterShort/ExitLong/ExitShort methods and NinjaTrader will try and manage the position to reduce the amount of code necessary for the script to function, but has rules to prevent unwanted positions.

              Thank you so much ChelseaB,

              I will keep things simple and only focus on the managed approach

              When i review the back testing chart, I do notice that even though my stop loss is not reached a long or short signal occurs because the strategy conditions is true. So I can see the managed approach is working.


              Where in this guide does it discuss that NT will close the buy order if strategy signals a short signal?

              Thanks

              Comment


                #8
                Hello simple_goodoboy,

                From the help guide on the Managed Approach in the section 'Entry Methods':
                "Entry methods are used to submit orders that create a market position if none exists or to reverse an existing position."


                It doesn't really go into detail on how it achieves a reversal, it just lets you know that Entry methods are used to reverse a position.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Waxavi, Today, 02:10 AM
                1 response
                16 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Started by Kaledus, Today, 01:29 PM
                5 responses
                13 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by Waxavi, Today, 02:00 AM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Started by alifarahani, Today, 09:40 AM
                5 responses
                23 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by gentlebenthebear, Today, 01:30 AM
                3 responses
                17 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X