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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      79 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X