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

Automaticaly exit a postion and take profit..??.. MIT order..?

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

    Automaticaly exit a postion and take profit..??.. MIT order..?

    Hello,

    It there a way to exit a long postion (or short), and take profit automatically using the Strategy builder.. is that by using an MIT order within Strategy Builder..? If so.. How is it done..?

    Thanks
    Michael

    #2
    Hello Michael,

    Thanks for your post.

    In the strategy builder you can use the SetStopLoss and SetProfitTarget to exit the orders that the strategy enters. Please see, "Understanding the Stops and Targets screen" https://ninjatrader.com/support/help...er_screens.htm

    If you are trying to place manual entries and have the strategy exit them, then no, the strategy would be unaware of manually entered orders. For manually placed orders you can use ATMs to handle the profit/stop: https://ninjatrader.com/support/help...gement_atm.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Paul,

      Thank you..

      I've watched that video months ago.. It really doesn't answer my question.. I'm still fuzzy on how the MIT works in the Strategy Builder as far as creating an automated trading setup..
      Lets say for instance I'm in a Long position in a substantial uptrend... When the slope of the moving average line I'm using changes from positive to negative in an uptrend, can I collect whatever profit that has accumulated from being in that Long position by exiting and taking profit..? I'm trying to profit from all the longs in an uptrend and skip the shorts in between the longs by exiting the long, skipping the short, and resuming the uptrend..
      in effect, your stop loss would be exiting the trade when the line changes to negative..
      Profit on the positve slope, exit and take profit when the line turns negative.. Does this make sense to you...?

      Michael

      Comment


        #4
        Hello Michael,

        Thanks for your reply.

        Regarding, " When the slope of the moving average line I'm using changes from positive to negative in an uptrend, can I collect whatever profit that has accumulated from being in that Long position by exiting and taking profit..?" The only way to collect profit is to close the trade. To answer your question, Yes, you can create a set that first checks to see that you are in a long position, then checks that your exit condition is true and for the action you can use "exit long position by a market order" This would exit the trade as soon as the conditions were true.


        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks Paul..!!

          Comment


            #6
            Paul,

            There is no "Market Order" to choose from in the order management window.. The options to choose from are, limit order, stop order, stop limit order, market-if-touched order.... If it is the MIT do I just ignore where it says "Stop Price"..?

            Michael
            Last edited by Mykro; 09-12-2019, 02:10 PM.

            Comment


              #7
              Hello Michael,

              Thanks for your reply.

              A market order, to exit a long position, in the strategy builder would show as "Exit Long Position" in the order management folder.

              A Market if Touched order (MIT) would place a limit like order but when price touches it, it would change to a market type order to fill immediately at the price convenience of the market. This type order does require a stop price to set the level to check. For the exit long position by a market-if-touched type order, you would have to place the order below the current price. Please note that this type of order, if not filled on the bar it is placed would be automatically canceled.
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Thanks Paul..

                And all of this time I thought that the "Exit Long" and the "Exit Short" positions within the order management window was something different..
                That it only gave you the option just to exit and "give up" or "quit" your position.. I had no idea it was a market order option... Thank you for the clarification...

                Michael

                Comment


                  #9
                  Paul, ....or to whom it may concern

                  I have a small delimma with what I'm trying to accomplish with this setup... I hope you can help..
                  I have attached a screen shot of what I've got so far.. The image shows the Exit Long where the positive slope changes to negative, which it does.. The problem is the exit goes a few bars too far past the positive side of the slope to the negative side of the slope and in the process up to 4 ticks can be lost..(view image).. I've done everything I know up to this point of trying to get it to end on the bar where the last green candle is next to the 1st red candle at the top of the slope.. (Or even a bar shy of that would be ok).
                  Is there a fix for this..? Any suggestions on how to accomplish this..?





                  Click image for larger version

Name:	Exit Long.jpg
Views:	1014
Size:	171.2 KB
ID:	1070906

                  Comment


                    #10
                    Hello Michael,

                    Thanks for your reply.

                    On live data, when a market order to exit is submitted (ExitLong()), it would be filled immediately so the issue is when is the order submitted. If you are using Calculate.OnBarClose, then the order can only be submitted at the end of the bar and likely be filled on the next bar. If you want the order to be filled sooner then you would need to either change the Calculate Mode or your conditions.

                    The Calculate Mode of Calculate.OnPriceChange would allow you to exit sooner in the bar however the strategy would be making decision with only partial bar data which may be different by the time the bar closes. I suspect that based on your description that you really want the order submitted 1 -2 bars sooner, so in that case I would suggest looking at your conditions that determine when an exit should occur and working with those to accomplish your goal.

                    You might consider testing to see if the slope is less on the current bar than it was on the previous bar indicating perhaps that the slope, while still positive, is decreasing. Of course you could also be faked out by a quick price pull back but by experimenting with various slope lengths (number of bars) you may find an exceptable level where you occasionally get faked out but more often than not you are exiting at a good point. You also may want to actually print out the values of slope that are being determined and see if that provides some insight.

                    You could also experiment with different moving average types to see if you can find a combination that gives you a crossover event that times nicely with your strategy.
                    Paul H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by alifarahani, Today, 09:40 AM
                    6 responses
                    31 views
                    0 likes
                    Last Post alifarahani  
                    Started by Waxavi, Today, 02:10 AM
                    1 response
                    17 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by Kaledus, Today, 01:29 PM
                    5 responses
                    14 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 gentlebenthebear, Today, 01:30 AM
                    3 responses
                    17 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X