Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trailing stop not trailing

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

    Trailing stop not trailing

    I am having an issue where my strategy trailing stop is not trailing the price.

    In the Initialize() method I have SetTrailStop(300);

    Say I have long entry, the price goes in my favor $400 (profit) then reverses. I would expect to be stopped out with a $100 profit. Instead the stop is not executed and I get stopped out with a $300 loss. It seems to be behaving as a SetStopLoss order not a trailing stop.

    What am I doing wrong? Do I need to update the SetTrailStop on each OnBarUpdate?

    Thanks

    #2
    Hello seahn,

    Thank you for your post.

    Do you have SetStopLoss() set anywhere in your code? Is it set in the Intialize() or OnBarUpdate() method?

    Do see any partial fills before the final exit at $300 below your entry price?

    I look forward to your response.

    Comment


      #3
      I do not have SetStopLoss anywhere in the code and trading 1 contract so no partial fills.

      I did notice that I placed SetTrailStop(300) in the OnStartUp() method not Initialize(). Would that make a difference?

      Comment


        #4
        Hello seahn,

        Thank you for your response.

        That would in fact make a difference. Make sure SetTrailStop() is only set in the OnBarUpdate() or Initialize() methods.

        Please let me know if this item continues after placing SetTrailStop() in the correct method.

        Comment


          #5
          I have tried (in backtest) to place SetTrailStop(300) in Initialize(), OnBarUpdate() also changed the placement in the method etc. same results SetTrailStop(300) is equivalent to SetStopLoss(300);

          I have found that SetTrailStop(CalculationMode.Ticks,30) appears to work (GC futures $300=30 ticks). It appears there is a bug in the SetTrailStop() implementation?

          Unfortunately this will require my strategy to be non-generalized as I will have to tell it the tick price. Also, I have found that it is not possible to pass parameters via the parameters list into a strategy Initialize() method as the results are unpredictable.

          Any Ideas on how to get around that?
          Last edited by seahn; 02-11-2013, 10:09 PM.

          Comment


            #6
            Originally posted by seahn View Post
            I have tried (in backtest) to place SetTrailStop(300) in Initialize(), OnBarUpdate() also changed the placement in the method etc. same results SetTrailStop(300) is equivalent to SetStopLoss(300);

            I have found that SetTrailStop(CalculationMode.Ticks,30) appears to work (GC futures $300=30 ticks). It appears there is a bug in the SetTrailStop() implementation?

            Unfortunately this will require my strategy to be non-generalized as I will have to tell it the tick price. Also, I have found that it is not possible to pass parameters via the parameters list into a strategy Initialize() method as the results are unpredictable.

            Any Ideas on how to get around that?
            You do not have to tell the strategy the ticksize; instead just use the ticksize to calculate how many ticks are represented by your stop loss currency amount, and pass that to the SetTrailStop method.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            633 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            567 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X