Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to set 2 or more profit targets?

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

    How to set 2 or more profit targets?

    I am trying to make a strategy where I scale out of a position. E.g. I bought 400 shares of SPY at $90 and would like to sell 200 shares at $92 and 200 shares at $94. I tried to use the following code in the strategy but all 400 shares get filled at $92 even though price went on and hit $94.

    if(Close[0] >= 90){
    EnterLong(
    400,"Long");
    ExitLongLimit(
    200, 92 ,"ProfitTarget1","Long");
    ExitLongLimit(
    200, 94 ,"ProfitTarget2","Long");}

    Not sure what I can do to get the strategy to ignore the ProfitTarget1 if it is already filled?

    #2
    tjendra, you would need to scale in to scale out this way. Please use two entry orders and then you can set two different profit targets for each partial position.
    BertrandNinjaTrader Customer Service

    Comment


      #3

      Comment


        #4
        Thanks for the link tortexal.

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          tjendra, you would need to scale in to scale out this way. Please use two entry orders and then you can set two different profit targets for each partial position.
          I change the code to the following. The ExitLongLimit orders works fine now but the ExitLongStop orders doesn't execute.

          if(Close[0] >= 90){
          EnterLong(2
          00,"Long1");
          EnterLong(200,"Long2");
          ExitLongLimit(
          200, 92 ,"ProfitTarget1","Long1"
          );
          ExitLongLimit(
          200, 94 ,"ProfitTarget2","Long2");

          ExitLongStop(200, 88 ,"Long1");
          ExitLongStop(200, 88 ,"Long2");}

          Comment


            #6
            i *think* you can just do this:
            ExitLongLimit(92 ,"ProfitTarget1","Long1");
            ExitLongLimit(
            94 ,"ProfitTarget2","Long2");

            ExitLongStop(88,"Long1");
            ExitLongStop(88,"Long2");}

            i dont use lmt orders so above is prob not exactly right
            but you can set it up that when your target is hit, just refer to the order by name OR when target is hit ExitLong() will close out all positions at one time in 1 order which will save on comish

            Comment


              #7
              Thanks for the input tortexal - tjendra, did you check the TraceOrders output for additional info concerning your ExitLongStop?

              BertrandNinjaTrader Customer Service

              Comment


                #8
                Originally posted by tortexal View Post
                i *think* you can just do this:
                ExitLongLimit(92 ,"ProfitTarget1","Long1");
                ExitLongLimit(
                94 ,"ProfitTarget2","Long2");
                ExitLongStop(88,"Long1");
                ExitLongStop(88,"Long2");}

                i dont use lmt orders so above is prob not exactly right
                but you can set it up that when your target is hit, just refer to the order by name OR when target is hit ExitLong() will close out all positions at one time in 1 order which will save on comish
                Thanks for the change, it was a typo on my previous post, with the "200", it won't compile. The ExitLongStop(88,"Long1") order still doesn't execute. Not sure whether I have to set it to "LiveUntilCancelled" for it to execute?

                Comment


                  #9
                  that could be, ive never used lmt order syntax. i write separate functions for targets and stopping out and then do so w mkt orders. check page 454 NT manual for lmt order info
                  Last edited by tortexal; 06-08-2009, 09:35 AM.

                  Comment


                    #10
                    tjendra, the TraceOrder output would show you if this expires or not...if you don't set this to liveUntilCancelled it will only last for one bar per default.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_Bertrand View Post
                      tjendra, the TraceOrder output would show you if this expires or not...if you don't set this to liveUntilCancelled it will only last for one bar per default.
                      Hi Bertrand,

                      I got the below from the log. It seem both the Profit Target Limit order and the Stop order was cancelled because they expired. Does that mean for both types of orders, I have to use the liveUntilCancelled option to get it to work properly?

                      20-May-09 3:25:00 PM Cancelled expired order: BarsInProgress=0: Order='NT-00048/Sim101' Name='ProfitTarget1' State=Working Instrument='SPY' Action=Sell Limit price=91.4 Stop price=0 Quantity=200 Strategy='Scaling' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='c9c492fc4fdf4c2aa37c983a2314ae41' Gtd='01-Dec-99 12:00:00 AM'
                      20-May-09 3:25:00 PM Cancelled expired order: BarsInProgress=0: Order='NT-00049/Sim101' Name='Sell' State=Working Instrument='SPY' Action=Sell Limit price=0 Stop price=90.5 Quantity=0 Strategy='Scaling' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='3c0a158bd9bb41efb1e43a793630cdd8' Gtd='01-Dec-99 12:00:00 AM'
                      2

                      Comment


                        #12
                        Yes, this is expecxted. Either set them to liveUntilCancelled or resubmit them until you're filled.

                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_Bertrand View Post
                          Yes, this is expecxted. Either set them to liveUntilCancelled or resubmit them until you're filled.

                          http://www.ninjatrader-support.com/H...verview36.html
                          For such orders, do they cancel at the end of trading session by themself if I set my strategy to execute from 9:30am to 4:00pm or will it still be live?

                          Comment


                            #14
                            If set to TIF=Day they will expire.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_Josh View Post
                              If set to TIF=Day they will expire.
                              Thanks Josh. In your post "Scaling out of a position", you use a trailing stop to change the stop price when scaling out of a position. If I want to use ExitShortStop(); to change the stop price when the 1st profit target is hit, how should I test whether the 1st profit target is hit and how would you amend the ExitShortStop(); order to a new stop price? Would the previous ExitShortStop(); order be cancelled if a new one is put in?
                              Last edited by tjendra; 06-09-2009, 01:00 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by bortz, 11-06-2023, 08:04 AM
                              47 responses
                              1,605 views
                              0 likes
                              Last Post aligator  
                              Started by jaybedreamin, Today, 05:56 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              18 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              13 views
                              0 likes
                              Last Post Javierw.ok  
                              Working...
                              X