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 NullPointStrategies, Today, 05:17 AM
      0 responses
      51 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      129 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      69 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X