Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Modifying setstoploss

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

    Modifying setstoploss

    Hello,

    I added in onbarupdate a condition to prevent NT from moving stoploss back to the value of setstoploss once I moved stoploss manually during the trade. I thought instead of adding a bool I simply use the barnumbers so that with next bar after entry (barNumberOfOrder=CurrentBars[2] together with entrylong...) NT will not move the stoploss, but it seems it does move stoploss also when CurrentBars[2]>barNumberOfOrder.

    if (Positions[4].MarketPosition != MarketPosition.Long)
    {
    if(barNumberOfOrder==CurrentBars[2])
    {
    SetStopLoss("rL1a", CalculationMode.Ticks, st1L1, false);​
    SetStopLoss("rL1b", CalculationMode.Ticks, st2L1, false);​
    ....
    ....
    }

    What do I miss to make it working please?

    Thank you!
    Tony

    #2
    Hello tonynt,

    There is not enough information in the code here to tell how the condition would equate. You could use a Print to see why that condition is happening still.

    Code:
    Print( barNumberOfOrder + " == " + CurrentBars[2]);
    if(barNumberOfOrder==CurrentBars[2])


    Comment


      #3
      Hello Jesse,

      thank you for your reply. I experience issues with the "conditional" setstoploss. I do not feel good with this solution, so I did a workaround and another aproach to achieve what I want.

      Thank you for your support!

      Tony

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      428 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      279 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      241 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      327 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      290 views
      0 likes
      Last Post CarlTrading  
      Working...
      X