Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

scaling out...via ExitLong/ExitShort

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

    scaling out...via ExitLong/ExitShort

    I've read a few places on this forum that in order to scale out we are required to scale in. Say we want to exit a 50-lot order with two different 25-lot exits. In order to do this, we NEED to create two 25-lot orders and enter the market with those two in order to exit at different points.

    However, I started looking at the code for ExitLong and ExitShort and noticed a few things. I wanted to know whether this is possible.

    1. Enter 1 long 50-lot order named "longOrder" (EnterLong(50, "longOrder"); )
    2. Create 2 ProfitTarget orders and 2 StopLoss orders like this:


    ExitLongLimit(25, 1000, "pt1", "longOrder");
    ExitLongLimit(25, 1250, "pt2", "longOrder");

    ExitLongStop(25, 950, "sl1", "longOrder");
    ExitLongStop(25, 900, "sl2", "longOrder");


    Won't this scale out the original 50-lot order. In addition to scaling, isn't this code essentially doing what SetStopLoss and SetProfitTarget do?


    Thanks!
    jon

    #2
    Jon,

    That doesn't work because even though you exit 25, it closes that exit signal name. The next time you come across the ExitLongLimit() for that same signal name it will say the position is closed because the signal name has been closed.

    To scale out without scaling in would require advanced programming in NT7.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh,

      Then why allow for a quantity in the overloaded function of ExitLongLimit?
      Please explain this 'advanced programming in NT7'. I've been a .NET programmer for the past 6 years and will be able to comprehend it.
      Every time this comes up somebody from NT posts a paragraph from the NT7 new features link. Anything more explicit you can share??

      thanks!
      jon

      Originally posted by NinjaTrader_Josh View Post
      Jon,

      That doesn't work because even though you exit 25, it closes that exit signal name. The next time you come across the ExitLongLimit() for that same signal name it will say the position is closed because the signal name has been closed.

      To scale out without scaling in would require advanced programming in NT7.

      Comment


        #4
        Jon,

        The quantity is for people not working off of scale ins and scale outs. You will need to use separate entry signals if you wish to scale out properly without risk of running into signal tracking issues.

        NT7 provides you a submission method that does not use any internal signal tracking logic. This allows you full control of everything which means you can decide exactly how you want to place the orders. If you would like to try this for yourself please send a note to sales [at] ninjatrader [dot] com to be included into our beta program. The order submission method you will be interested in is our Unmanaged orders.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Josh,

          Thank you. I think this is something that is absolutely needed with NS. I am part of the beta program, do you have any documentation or links that describe this Unmanaged orders feature (something explicit and descriptive)?

          thanks-


          Originally posted by NinjaTrader_Josh View Post
          Jon,

          The quantity is for people not working off of scale ins and scale outs. You will need to use separate entry signals if you wish to scale out properly without risk of running into signal tracking issues.

          NT7 provides you a submission method that does not use any internal signal tracking logic. This allows you full control of everything which means you can decide exactly how you want to place the orders. If you would like to try this for yourself please send a note to sales [at] ninjatrader [dot] com to be included into our beta program. The order submission method you will be interested in is our Unmanaged orders.

          Comment


            #6
            Jon,

            Please search the Help Guide for Unmanaged, SubmitOrder(), CancelOrder().
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Unfortunately the help guide has an empty page for the SubmitOrder() page that says "Enter topic text here". Any more information?

              Originally posted by NinjaTrader_Josh View Post
              Jon,

              Please search the Help Guide for Unmanaged, SubmitOrder(), CancelOrder().

              Comment


                #8
                Unfortunately not at this point in time. You can try using the IntelliSense to pick up the signatures. It works very simply. SubmitOrder() is used to make all of your orders. You tell it what direction you want and it will do it. There is no signal tracking whatsoever by NinjaTrader and everything needs to be stored in your own IOrder objects if you want to reference them again later.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  SubmitOrder more info

                  What should be the limitPrice, if I am submitting a stopOrder - I am using advanced programming techniques for SubmitOrder.

                  should LimitPrice be 0 or the StopPrice value

                  Comment


                    #10
                    If you are trying to do a stop order then put 0 as the limit price. If you are trying to do a limit order put 0 as the stop price.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Position Check in OnOrderUpdate

                      Lets say I am using advanced order management using OnOrderUpdate

                      Can I check my Position in this method, meaning can i say stuff like:

                      If(Position == Long && "Got Filled on Entry Order")
                      {
                      Send ExitOrder of type trailing (trailing Managed in Code");
                      }

                      So assuming I got filled on a long order, Will Position == Long be true?

                      Comment


                        #12
                        Submit Order question

                        I am deciding to post this question since i was able to get information on my previous question by stepping through the debugger.

                        1. Here is my assumption and please clarify if its true

                        Position object gets updated before "OnOrderUpdate" event is fired by the Ninja Framework, so it would be OKAY to check the Position.AvgPrice and if the position is long or short in the OnOrderUpdate method

                        2. Here is my other questions
                        longStopLossOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Stop, Position.Quantity, 0, longStopLossPrice, order.Name, longStopLossOrderType_tag);

                        Lets say i am short and I am generating a stop loss order which will be simulated in OnBarUpdate method as new stops are determined.
                        Does it make a difference if I use OrderAction.Buy or OrderAction.BuyToCover?

                        All of the above is being performed in the OnOrderUpdate method

                        Thanks in advance

                        Comment


                          #13
                          1. No, position update is the last thing that gets updated. The sequence is OnOrderUpdate -> OnExecution -> OnPositionUpdate.

                          2. It makes a difference submitting Buy vs BuyToCover. Submitting buy means enter the market long. Submitting BuyToCover means close your short position. You need to submit the correct order type as this is required by the brokerage.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            More information on Position Object

                            Thanks for the clarification.

                            However you Ninja has an Object Strategybase.Position which contains the following fields / functions
                            1. AvgPrice
                            2. BreakEven
                            3. GetProfitLoss
                            4. MarketPosition
                            5. Quantity
                            6. ToString()

                            Is this object [Position] updated before OnOrderUpdate is triggered. What I am trying to do is check for my Position.Quantity and trigger StopLoss quantity based on that?

                            If this is not the correct method to go about it, what would you recommend maintaining the correct state of the Position and being able to look it up?

                            Thanks

                            Comment


                              #15
                              No, that is all updated in OnPositionUpdate which is after OnOrderUpdate.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              649 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              370 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              573 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              576 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X