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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      135 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X