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

Exiting Positions Question

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

    Exiting Positions Question

    Hi,

    I have a situation in which I cannot seem to figure out how to exit a position. Here is the scenario: I enter a long position on stop, and the entry triggers. Therefore I am now long one contract. On the next bar, I get a signal stating that I should reverse my position to a short, 1 contract. Okay. I execute the following

    entryOrder = EnterShortStop(0, true, DefaultQuantity, entryPrice, "Long->ShortEntryReversal");

    So far so good. Here is the issue. The short entry does not trigger because the stop price is not reached. As far as the strategy is concerned, however, I am still long. Is there a way to kill the long position? Also, is there a way to exit a position with a market order when the position was entered on stop? Thank you.

    #2
    Hello Zeos6,

    You can exit a long position with ExitLong(). This will submit sell exit order for the long position.

    I do not recommend submitting the ExitLong() and EnterShortStop() on the same bar update as this will cause you to go into the short position with double the positions you may have wanted.
    http://www.ninjatrader.com/support/h...l?exitlong.htm

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi Cal,

      Thank you for your reply. So if I understand you correctly, if I have entered a long position on stop, I can exit that position anytime with a market order by using ExitLong(). I would however like to exit the long and enter the short on the same bar. Is there a way to do this?

      Comment


        #4
        Zeos6,

        With the Managed approach, if you submit an entry order for the opposite direction it will close out the position and enter the new position.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Hi Cal,

          Yes, that is true but if the new position does not trigger, it means you are still in the initial position. In other words, if I am long and I enter a short on stop but the short has not yet triggered, I am still long, which I do not want to be. Can this be handled better with the unmanaged approach?

          Comment


            #6
            Zeos6,

            At this point you would want to implement additional logic that if the Stop doesn't get filled then it would get out of the long position.

            With the unmanaged approach you can have it so that it exits the long before entering the short position as well without the double entry of the positions.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Hi Cal,

              Thank you. The control of the unmanaged approach is what I was looking for. I think what you are telling me is that I could exit the long and enter the short on the same bar, in addition to avoiding the double position entry that comes with the managed approach.I will modify the strategy for the unmanaged approach to get the level of control I need.

              Thanks for all your help.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by RaddiFX, Today, 10:15 AM
              2 responses
              14 views
              0 likes
              Last Post RaddiFX
              by RaddiFX
               
              Started by patrickmlee007, Today, 09:33 AM
              2 responses
              17 views
              0 likes
              Last Post patrickmlee007  
              Started by magnatauren, 08-15-2020, 02:12 PM
              5 responses
              206 views
              0 likes
              Last Post RaddiFX
              by RaddiFX
               
              Started by rene69851, 05-02-2024, 03:25 PM
              1 response
              22 views
              0 likes
              Last Post rene69851  
              Started by ETFVoyageur, Yesterday, 07:05 PM
              5 responses
              45 views
              0 likes
              Last Post ETFVoyageur  
              Working...
              X