Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Profit target for all position.

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

    Profit target for all position.

    Hi.
    How to set profit target to close all possition when one possition reach profit target??
    Czarek.

    #2
    Modify the price of all outstanding profit target orders by calling SetProfitTarget() again with a price below market to sell (for example) and then once flat, call all SetProfitTarget() methods again to reset to the original value in the Initialize() method.
    RayNinjaTrader Customer Service

    Comment


      #3
      It will be great if you show me code sample?

      Comment


        #4
        Here is something close - http://www.ninjatrader-support.com/v...ead.php?t=3222
        RayNinjaTrader Customer Service

        Comment


          #5
          This sample concer stop loss modyfication to breakeven. Can you give something closer to my case??
          Rgds

          Comment


            #6
            That is the closest reference we have. First you will want to be aware of when to close out all your positions. This can be done by manually checking the PnL of your orders to know when your order should fire off the Profit Target. When that occurs just do Ray's suggestion to modify all the prices below market for your other Profit Targets.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Hi Josh.
              Could you type few lines of code refer to modify all outstanding profit tragets. I hope such prompt will help me a lot. Thanks.
              Czarek

              Comment


                #8
                Unfortunately we can not since we do not provide coding assistance. The reference sample demonstrates clearly how to approach what you need. It makes not difference if it is SetStopLoss() or SetProfitTarget() the concept is identical.

                Here is further guidance:

                if (flat)
                SetProfitTarget(with same parameters used in Initialize() method);

                if (condition to move profit targets is true)
                SetProfitTarget(with new price here)
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Ray
                  Ok, let's say 2 entries per direction.
                  So should I put as condition to move profit targets same condition as conditon for second entry?
                  Than, SetProfitTarget(with new price here). How to describe this price? This price should be based on first entry price and stop limit tick. What is the syntax of this condition?
                  Czarek

                  Comment


                    #10
                    I can't tell you what condition you should use, that is dependant on you. The new price needs to be a price where the order will fill at, for example if you were long:

                    SetProfitTarget(CalculationMode.Price, GetCurrentBid() - 15 * TickSize);

                    This would modify the profit limit order price to the bid minus 15 ticks which should fill the order immediately.
                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      Ray.
                      Let's take a look for this sample:
                      We concider long position only.
                      Enter per direction =2
                      SetStopLimit is in Initialize() method
                      Stop Limit 20 ticks
                      First enter is with 100 price, so stop limit is set for 120 automaticly.
                      Second enter is 105 price, so the limit is set 125 automaticly.
                      What want to do is move this second entry's stop limit from 125 to 120 because I want to close both positon same time.
                      So I think to make like this: if (there I put same conditions as for second entry or quantity must be equal 2) - HOW
                      {
                      SetStopLoss(CalculationMode, FISRT ENTRY PRICE + 20 TickSize)
                      I only have to thinks I do not know:
                      how to describe FIRST ENTRY PRICE
                      how to set condition: quantiry must be equal 2

                      Can you help me with this 2 things?
                      Czarek

                      Comment


                        #12
                        To scale out you need to have unique order entry names and unique SetStopLoss() for each. Then you can call the relevant SetStopLoss() inside the OnBarUpdate() method where you entered your trade and make the modification needed. Please see this reference sample: http://www.ninjatrader-support.com/v...ead.php?t=3751

                        To determine if a second entry order has been filled you can just check your overall position size with Position.Quantity.

                        Code:
                        if (Position.Quantity > 1)
                           // Blah blah
                        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
                        571 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        331 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        101 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        549 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        550 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X