Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

profittarget-exitorderhandling

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

    profittarget-exitorderhandling

    Hello,

    it occurs frequently that the stop is moved with certain ticks but I´m not filled for 1st profit-target at the same number of ticks.

    So I want to manage the profittarget in onExecution, as I do with stops.

    But now I don´t know how to work with setprofittarget so that I can grab it in onexecution so that I have

    "if 1st profit-target filled then move stoploss"

    Thank you
    Tony

    #2
    Hello Tony,

    Code:
    protected override void OnExecution(IExecution execution)
    {
    	if (execution.Name == "Profit target")
    	{
    		// execute code
    	}
    }
    In the future, you can find information to identify an execution by printing the execution information.
    Print(execution.ToString());
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you for your reply. So simply to do

      Initialize
      SetStopLoss("iLa", CalculationMode.Ticks, 8, false);
      SetStopLoss("iLb", CalculationMode.Ticks, 8, false);

      SetProfitTarget("iLa", CalculationMode.Ticks, 3);
      SetProfitTarget("iLb", CalculationMode.Ticks, 10);

      onExecution

      if(execution.Name=="iLa")
      SetstopLoss("iLb",CalculationMode.Price, Position.AvgPrice-2*TickSize, false);

      Only this here above? Without the order-handling like in sampleOnOrderUpdate with "targetOrder"? Or to do like in sampleOnOrderUpdate?

      Thank you
      Tony

      Originally posted by NinjaTrader_ChelseaB View Post
      Hello Tony,

      Code:
      protected override void OnExecution(IExecution execution)
      {
          if (execution.Name == "Profit target")
          {
              // execute code
          }
      }
      In the future, you can find information to identify an execution by printing the execution information.
      Print(execution.ToString());

      Comment


        #4
        Hello Tony,

        No that is not correct. The execution.Name will not be fromEntrySignal of the entry order. The execution.Name for a profit target is 'Profit target'.

        Try printing the execution.ToString() and see what prints when you visually see the profit target fill.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea,

          PLEASE can you change me the one line you mean or do you want me to make another 1054 posts in the forum?

          "Only a small snippet for you but a big help for me". Thank you!

          I dont understand how with "Profit target" I can refer to a certain exit?

          I dont want to learn programming after all and I have no efforts anymore after all of this. Please can you help me this small last step.

          Thank you
          Tony


          Originally posted by NinjaTrader_ChelseaB View Post
          Hello Tony,

          No that is not correct. The execution.Name will not be fromEntrySignal of the entry order. The execution.Name for a profit target is 'Profit target'.

          Try printing the execution.ToString() and see what prints when you visually see the profit target fill.

          Comment


            #6
            Hello Tony,

            If you want to know when a profit target has filled, look for the execution name 'Profit target'.

            If you want to know the fromEntrySignal of the order use:

            if (execution.Name == "Profit target" && execution.Order.FromEntrySignal == "entry order signal name")
            {
            }

            where "entry order signal name" is the signal name of the entry order.

            This is the actual code you would use not psuedo-code.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello,

              thank you for your reply. In my executions tab I see "Target1" and "Target2" but I dont see "Profit target". This will work in onExecution?

              Thank you
              Tony

              Comment


                #8
                Hello Tony,

                May I confirm those orders were placed by your strategy and not manual orders with an Atm Strategy applied?

                What prints when you print the execution.ToString()?

                Please copy the output from the output window to your next post.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Chelsea,

                  thank you for your reply. As I have simply setprofittarget in initialize and not exitorderhandling in onexecution I really have no idea where to put the execution.ToString() for having this in the output window.

                  Thank you
                  Tony

                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello Tony,

                  May I confirm those orders were placed by your strategy and not manual orders with an Atm Strategy applied?

                  What prints when you print the execution.ToString()?

                  Please copy the output from the output window to your next post.

                  Comment


                    #10
                    Tony,

                    protected override void OnExecution(IExecution execution)
                    {
                    Print(execution.ToString());
                    }
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello,

                      thank you for your reply and your help.

                      The output window shows

                      Execution='91a15a3553ec4a67b15a67f710a3c0d9' Instrument='ES 09-15' Account='Sim101' Name='Profit target' Exchange=Default Price=2087 Quantity=1 Market position=Short Commission=0 Order='bf3bf4bc0fc9474e886688eb1abeda5d' Time='7/28/2015 2:52:52 PM'

                      and the stop has been move where I want it.

                      For your information I run a script for the trade. Only in between I run an ATM when I had issues with the strategy.

                      Do I understand right that the exits from the ATM are shown with Target1 and Target2 while exits from the script are shown with "Profit target" (But why doesn´t the executions tab show which Target it is for the script?)

                      Thank you for all your support. You guys are great!

                      Best
                      Tony
                      Last edited by tonynt; 07-28-2015, 01:04 PM. Reason: translation error

                      Comment


                        #12
                        Hi Tony,

                        That is correct. When placing a trade with an Atm Strategy applied, (even when using AtmStrategyMethods) NT will name the profit targets 'Target1', 'Target2', and 'Target3'. When using SetProfitTarget() the order will always be named 'Profit target'.

                        From your print:
                        Name='Profit target'

                        This execution was named Profit target. If this was a live order, you will see it on the chart named Profit target.

                        If you place your own exit orders with ExitLongLimit or ExitShortLimit instead of using SetProfitTarget(), then you can name your orders anything you want.

                        Or you can also use the FromEntrySignal of the Order object from the execution to see what the SetProfitTarget() as I have suggested in post #6.
                        Last edited by NinjaTrader_ChelseaB; 07-29-2015, 07:54 AM.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by bmartz, 03-12-2024, 06:12 AM
                        5 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_Zachary  
                        Started by Aviram Y, Today, 05:29 AM
                        4 responses
                        13 views
                        0 likes
                        Last Post Aviram Y  
                        Started by algospoke, 04-17-2024, 06:40 PM
                        3 responses
                        28 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by gentlebenthebear, Today, 01:30 AM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by cls71, Today, 04:45 AM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Working...
                        X