Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetTrailStop not working, but SetStopLoss works???

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

    SetTrailStop not working, but SetStopLoss works???

    Hi,

    I am trying to use the SetStopLoss and SetTrailStop methods in my strategy, and one works but the other doesn't...

    For example:
    Code:
    SetStopLoss(CalculationMode.Percent, 0.25)
    Performs exactly as you would expect. When you view the trade collection in the optimizer summary window, you can clearly see that there are a bunch of stop losses being triggered where they are supposed to be (approx 25%)

    However, if I try to use SetTrailStop in exactly the same way:
    Code:
    SetTrailStop(CalculationMode.Percent, 0.25)
    It does not perform at all as you would expect. All of the trades have a stop loss that is triggered in the first bar, and the stop loss values range from 1-2%

    What could be causing this? I am at a bit of a loss

    Thanks

    #2
    While this may not be a factor here the SetTrailStop() method can not be used concurrently with the SetStopLoss() method for the same position, if both methods are called for the same position (fromEntrySignal) the SetStopLoss() will always take precedence. You can however, use both methods in the same strategy if they reference different signal names.

    I would suggest using signal names if you are using both these int he same script.


    If this does not resolve the issue please attach a simplified version of the script that replicates the issue.
    Located in (MY)Documents\NinjaTrader 7\bin\Custom\Strategy
    LanceNinjaTrader Customer Service

    Comment


      #3
      Originally posted by kbeary33 View Post
      Hi,

      I am trying to use the SetStopLoss and SetTrailStop methods in my strategy, and one works but the other doesn't...

      For example:
      Code:
      SetStopLoss(CalculationMode.Percent, 0.25)
      Performs exactly as you would expect. When you view the trade collection in the optimizer summary window, you can clearly see that there are a bunch of stop losses being triggered where they are supposed to be (approx 25%)

      However, if I try to use SetTrailStop in exactly the same way:
      Code:
      SetTrailStop(CalculationMode.Percent, 0.25)
      It does not perform at all as you would expect. All of the trades have a stop loss that is triggered in the first bar, and the stop loss values range from 1-2%

      What could be causing this? I am at a bit of a loss

      Thanks
      Is this in Bsacktest or live/quasi-live?

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X