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

Multiple Pfofit Targets

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

    Multiple Pfofit Targets

    I have a few questions:

    1) Is it possible to set multiple profit targets with the SetProfitTarget() method?
    2) Is it possible to auto enter but then exit manually?

    3)Is it possible to SetStopLoss() method based on# ofbars or time(ie if it does not advance/decline in X bars/minutes) get out


    Thanks


    #2
    imported post

    1) You could do this if you provide unique signal names for your entry, such as entry1, entry2 and then call SetProfitTarget () specifying each entry signal.

    2) Only by using ATM strategies. There is a section in the Help Guide on this topic.

    3) You can always exit using ExitLong() after X bars, any stop loss in the market will be cancelled. You do run the risk of getting filled on both order in this case so make sure the stop loss is a good distance from the market.

    Ray
    RayNinjaTrader Customer Service

    Comment


      #3
      imported post

      Thanks for the response. In regards to 1)

      I would like to enter all units at once and then take partial units off at specific targets. I'm guessing there is a way to this but it would be nice if the SetProfitTarget() method could provide this functionality.

      Thanks Again


      Comment


        #4
        imported post

        You can enter at once, but with two orders:



        Within Initialize()

        SetProfitTarget("Entry1", CalculationMode.Ticks, 6);
        SetProfitTarget("Entry2", CalculationMode.Ticks, 12);

        Within OnBarUpdate()

        if (Close[0] > Open[0])
        {
        EnterLong(1, "Entry1");
        EnterLong(1, "Entry2");
        }
        Then when running or backtesting a strategy, make sure you set the following parameters:

        Entries per direction = 1
        Entry handling = UniqueEntries

        Ray
        RayNinjaTrader Customer Service

        Comment


          #5
          Great thanks.

          Comment


            #6
            I just submitted same question.. See my post at Scale Out Partials . I attached the code __ Also got it working just fine.

            Comment


              #7
              Another question.

              I have two entries T1, T2. My T1 target is hit now I would like to bring my T2 original stop loss upto Break Even. Any idea how I can do this?

              Thanks.

              Comment


                #8
                You would need to check Position.Quantity to determine if T1 is hit. Then you can call the SetStopLoss() method with different parameters to tighten the stop loss.

                From the Help Guide:

                Definition
                Generates a stop loss order to exit a position. Stop loss orders are real working orders (unless simulated is specified in which case the stop order is locally simulated and submitted as market once triggered) submitted immediately to the market upon receiving an execution from an entry order.


                It is suggested to call this method from within the strategy Initialize() method if your stop loss price/offset is static
                You may call this method from within the strategy OnBarUpdate() method should you wish to dynamically change the stop loss price while in an open position
                Should you call this method to dynamically change the stop loss price in the strategy OnBarUpdate() method, you should always reset the stop loss price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Not sure if I'm doing this right:

                  Initialization:

                  SetProfitTarget("T1", CalculationMode.Ticks, 5);
                  SetProfitTarget("T2", CalculationMode.Ticks, 7);

                  SetStopLoss("T1", CalculationMode.Ticks, 10, true);
                  SetStopLoss("T2", CalculationMode.Ticks, 10, true);


                  OnBarUpdate: (not sure if this is how I modify the order)

                  EnterLong(2, "T1");
                  EnterLong(2, "T2");

                  if(Position.Quantity == 2)
                  {
                  SetStopLoss("T2", CalculationMode.Ticks, 0, true);
                  }

                  Comment


                    #10
                    I know in the ATM there are advanced stop loss orders which will trigger the stop loss to BE + X. It would be nice if we had a method to this.

                    Comment


                      #11
                      if(Position.Quantity == 2)
                      {
                      SetStopLoss("T2", CalculationMode.Price, Position.AvgPrice, true);
                      }


                      Then you have to reset this when flat:

                      if(Position.MarketPosition== MarketPosition.Flat)
                      {
                      SetStopLoss("T2", CalculationMode.Ticks, 10, true);
                      }
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        Great thanks Ray. Works great.

                        Appreciate your help.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by andrewtrades, Today, 04:57 PM
                        1 response
                        9 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by chbruno, Today, 04:10 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post chbruno
                        by chbruno
                         
                        Started by josh18955, 03-25-2023, 11:16 AM
                        6 responses
                        436 views
                        0 likes
                        Last Post Delerium  
                        Started by FAQtrader, Today, 03:35 PM
                        0 responses
                        8 views
                        0 likes
                        Last Post FAQtrader  
                        Started by rocketman7, Today, 09:41 AM
                        5 responses
                        19 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Working...
                        X