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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      56 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      132 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      73 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X