Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Paul H.NinjaTrader Customer Service

    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 burtoninlondon, Today, 12:38 AM
      0 responses
      5 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      13 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      13 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,982 views
      3 likes
      Last Post jhudas88  
      Working...
      X