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, 03-31-2026, 09:41 PM
      1 response
      47 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      23 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      33 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      51 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X