Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trailing stop

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

    Trailing stop

    Hi,

    I set up a strategy with a trailing stop. However, when I test it on historical data I have strange results: it seems that the stop is triggered without any reason, sometime exiting an entry I soon as it entered it. Have you already faced the same issue?

    Thanks

    My code:
    HTML Code:
    protected override void Initialize()
    {
    SetTrailStop("Buy", CalculationMode.Percent, StopLoss, true);
    CalculateOnBarClose = true;
    }
    Attached Files

    #2
    Manuel, what have you set StopLoss (the percentage) to please in this scenario?

    Comment


      #3
      Hello Bertrand, thank you for your reply. It is a double variable that I tested at 0.045.

      Comment


        #4
        I would suggest to test with a wider value then, as otherwise it might trail already on the entry bar for you.

        Comment


          #5
          But 0.045 represents a loss of 4.5 % if I understand correctly? As you can see on the printscreen, the stop loss is sometimes triggered the same day on the entry price.

          Comment


            #6
            Yes, correct - which chart are you testing on here?

            Comment


              #7
              I tested all the stocks on the S&P500. This printscreen is for the results of Xerox Corp from 2000 up to today.

              Thanks for your help!

              Comment


                #8
                Ok, but what interval you're working? Is that a daily chart series or intraday?

                Comment


                  #9
                  I tested on a daily chart

                  Comment


                    #10
                    Thanks. Can't seem to reproduce that here on my end, same for you if you'd tested with default qty of let's say 100 shares in your script?

                    Comment


                      #11
                      I tried with an account of 10 000. I will try with default quantity or 100 shares. What would be the difference?
                      I saw on other threads that people had an update issue with the trailing stop on backtesting. Do you think that it might be the same problem?

                      Comment


                        #12
                        I don't think so - must are running into an expected outcome when it start trailing with the entry bar already, for example for your chart, run with 0.11 as input - that should remove some if not all of the same bar exits.

                        Comment


                          #13
                          Thanks Bertrand. I tested it and it is true that it works with a trailing stop at 11%. But it is too low for me, why is it not possible to use a trailing stop at 4.5%

                          I tried with Default Quantity and 100 shares but it does not work neither at 4.5%.

                          Comment


                            #14
                            It would unfortunately not work as you expect with your lower figure as the trail would then be activated too early for your scenario on the entry bar, since your trail closely. You could workaround potentially by custom coding the trailing aspect to kick in later once the trade progresses.

                            Comment

                            Latest Posts

                            Collapse

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