Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetStopLoss Method move in one direction only

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

    SetStopLoss Method move in one direction only

    Hi, I use the setstoploss method for a trailing stop. as an example here is my stoploss after each candle 1 tick below the bottom of the last completed candle. how can i limit the direction to long only, so that with long only the long direction is followed? the stop at long should only be tightened in this direction and not in the opposite direction. in the picture you can see very well what I mean. the red dotted line is the current stoploss line and the yellow line is to become. i have been trying to find a solution for 2 days now and i just cannot come up with a good idea, there's certainly an easy way ;-)
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    #2
    Hello sidlercom80,

    Thanks for your post.

    You would need to create logic that compares the current stop position to the next position and if the next position is less than or equal to the current position then you do not change the stop. In pseudo code something like:

    if(nextstop > currentstop) // next level must be greater than the current stop level
    {
    SetStopLoss(nextstop); // adjust to next level
    currentstop = nextstop; // store the next level as the current stop level.
    }

    You would likely need to use a bool variable to know when the "initial" stop has been set to then enable the adjusting routine.

    Comment


      #3
      hello paulh thank you very much for the answer, i will test this
      sidlercom80
      NinjaTrader Ecosystem Vendor - Sidi Trading

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      87 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      134 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      118 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X