Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trailing Stop not working via Strategy Wizard

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

    #16
    If my understand is correct, what you mean is we can't set a universal trailing stop % for all entries, but will have to tag it to each label? If that is the case, I will try it again. Thanks for your tips.

    Comment


      #17
      Yes, each portion of your position would need a unique signal name. Please see our Reference Sample on Scaling out of a Position:

      MatthewNinjaTrader Product Management

      Comment


        #18
        Originally posted by Tarry View Post
        I have just started trying out writing some strategy, and is running into some trouble with trailing stop. I have tried both tick & percent, and tried both True & false, but it is apparently not functioning. I use some very obvious setting, like 5 ticks, 1% (0.01) for percent. Any idea where it could have been wrong?
        How do you mean: "it is apparently not functioning"? Is there an error message in your log?

        Comment


          #19
          Dear Koganam, the trailing stop just simply not executed. As Bertrand & Matthew pointed out that Ninjascript need unique label/tag for any entry, I guess this could be the problem. I am going to try out again tonight, and hope it solve the problem. Thanks again, all of you, and have a good day!

          I have tried to tag the trail stop, and it work! Thanks.
          Last edited by Tarry; 03-07-2013, 10:03 AM. Reason: Tried to suggestion

          Comment


            #20
            Trailing Stop Issues

            As you can see below - have commented out my SetStopLoss for target2. However, when i uncomment the SetTrailStop "target2" and compile and reload the ninja script on my chart, nothing changes. Entering long position with a target2 name. And have a SetProfitTarget for target 2. Does anything just out that is just too obvious for a non-programmer to see. FWIW have tried the SetTrailStop in the 'on initalize' and 'onbarupdate' section with same results.

            thanks in advance



            private void GoLong()
            {
            SetStopLoss("target1", CalculationMode.Price, Close[0] - (Stop * TickSize), false);
            // SetStopLoss("target2", CalculationMode.Price, Close[0] - (Stop * TickSize), false);
            SetStopLoss("target3", CalculationMode.Price, Close[0] - (Stop * TickSize), false);
            // SetTrailStop("target2", CalculationMode.Ticks, Close[0] - (16 * TickSize), false);

            SetProfitTarget("target1", CalculationMode.Price, Close[0] + (Target1*TickSize));
            SetProfitTarget("target2", CalculationMode.Price, Close[0] + ((Target1 + Target2)*TickSize));
            SetProfitTarget("target3", CalculationMode.Price, Close[0] + ((Target1 + Target2 + Target3)*TickSize));


            EnterLongLimit(0,true,1,Close[0] + (1 * TickSize), "target1");
            EnterLongLimit(0,true,1,Close[0] + 1 * TickSize, "target2");
            if(atarget3on)EnterLongLimit(0,true,1,Close[0] + 1 * TickSize,"target3");

            }

            Comment


              #21
              Originally posted by nanook77 View Post
              As you can see below - have commented out my SetStopLoss for target2. However, when i uncomment the SetTrailStop "target2" and compile and reload the ninja script on my chart, nothing changes. Entering long position with a target2 name. And have a SetProfitTarget for target 2. Does anything just out that is just too obvious for a non-programmer to see. FWIW have tried the SetTrailStop in the 'on initalize' and 'onbarupdate' section with same results.

              thanks in advance



              private void GoLong()
              {
              SetStopLoss("target1", CalculationMode.Price, Close[0] - (Stop * TickSize), false);
              // SetStopLoss("target2", CalculationMode.Price, Close[0] - (Stop * TickSize), false);
              SetStopLoss("target3", CalculationMode.Price, Close[0] - (Stop * TickSize), false);
              // SetTrailStop("target2", CalculationMode.Ticks, Close[0] - (16 * TickSize), false);

              SetProfitTarget("target1", CalculationMode.Price, Close[0] + (Target1*TickSize));
              SetProfitTarget("target2", CalculationMode.Price, Close[0] + ((Target1 + Target2)*TickSize));
              SetProfitTarget("target3", CalculationMode.Price, Close[0] + ((Target1 + Target2 + Target3)*TickSize));


              EnterLongLimit(0,true,1,Close[0] + (1 * TickSize), "target1");
              EnterLongLimit(0,true,1,Close[0] + 1 * TickSize, "target2");
              if(atarget3on)EnterLongLimit(0,true,1,Close[0] + 1 * TickSize,"target3");

              }
              I expect that the TrailStop is being set, but it is so far away that it does not show up on the chart. Have you checked the log?

              You are setting a TrailStop at Close[0] - (16 * TickSize) ticks. Hm. Let's see. For a $20.00 stock, that is (2000 - 0.16) ticks! I shudder to think how many ticks that statement represents on the /ES or /TF today.

              Comment


                #22
                Originally posted by koganam View Post
                I expect that the TrailStop is being set, but it is so far away that it does not show up on the chart. Have you checked the log?

                You are setting a TrailStop at Close[0] - (16 * TickSize) ticks. Hm. Let's see. For a $20.00 stock, that is (2000 - 0.16) ticks! I shudder to think how many ticks that statement represents on the /ES or /TF today.
                Thx - and must not be clearly understanding your message. The instrument if CL (oil) which of course trades in USD $0.01 increments. If i understand you correctly i would set the trailstop to 10 and not to (10 * TickSize) . At a $100.00 price, that would seem to mean that my trail stop is at $90.00 when in fact what i want it to be in 99.90.

                Can you please eloborate further on this as my understanding seems to be far afield. Thanks in advance.
                'nanook77

                Comment


                  #23
                  Originally posted by nanook77 View Post
                  Thx - and must not be clearly understanding your message. The instrument if CL (oil) which of course trades in USD $0.01 increments. If i understand you correctly i would set the trailstop to 10 and not to (10 * TickSize) . At a $100.00 price, that would seem to mean that my trail stop is at $90.00 when in fact what i want it to be in 99.90.

                  Can you please eloborate further on this as my understanding seems to be far afield. Thanks in advance.
                  'nanook77
                  I do not know what to say other than "ticks" are "ticks". If you want your TrailStop to be 10 ticks away, then specify 10 ticks, not a price. You did say CalculationMode.Ticks. That requires you to specify the number of ticks: no need for fancy arithmetic unless the result of said arithmetic is specified as a tick value. If you specify the Close[0] as the number of ticks, then your TrailStop is Close[0] ticks away. i.e., in your particular case, if the Close[0] is $100.00, then your TrailStop is 100 ticks away, which is, yes, $90.00.
                  Last edited by koganam; 03-09-2013, 08:31 AM.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  22 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  19 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  14 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  10 views
                  0 likes
                  Last Post TheRealMorford  
                  Started by Mindset, 02-28-2026, 06:16 AM
                  0 responses
                  41 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Working...
                  X