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 CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      67 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      202 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      366 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      283 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X