Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

stoploss not updating

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

    stoploss not updating

    Hi

    I would like to update my stoploss for my strategy automatically but it seems that it does not work. For example, if I start with an initial stoploss at -4% and once that I earn 3 % I move it to my average price+1%, the initial stoploss is cancelled but not updated.

    Here is the code that I use to update it:

    HTML Code:
    // Condition set 5
    if (Position.MarketPosition == MarketPosition.Long
    && Position.GetProfitLoss(Close[0], PerformanceUnit.Percent)> 0.03)
    {
    SetStopLoss("Buy Signal", CalculationMode.Price, Position.AvgPrice*1.01, false);
    }
    Any idea?

    Thank you,

    Manuel

    #2
    Hi Manuel, would do you mean by cancelled here? Is the order really removed or just your adjustment ignored? Did you check what output you get from the TraceOrders debug info in your output window?

    Comment


      #3
      Hello Bertrand,

      Thank you for your reply. The initial order is cancelled (and removed) and not replaced with the new one. What is even more strange is that now my strategy does not recognize the existing position in this specific stock. It recognize the other existing positions but not that one.

      I have not used the traceorders debug unfortunately...

      Comment


        #4
        Hi Manuel, so you mean the entry order is cancelled and thus no trade taken? This would be expected if you're not using a market order, as the other type order like limit entry would expire at the end of the bar they were placed on - which would be noted in your TraceOrders debug print to the output window (if that function enabled via your script's Initialize method). So to get around that you would need to either resubmit the order again (if your condition for entry is still present) or submit with the liveUntilCancelled parameter set to 'true' to begin with.

        Comment


          #5
          No, the issue is that my initial stoploss at -4% is not replaced with the stoploss at +1% now that I have a gain of 3 %. The initial stoploss is cancelled and not replaced with the one mentioned in my condition.

          Moreover, when I enable my strategy, NT does not recognize anymore this existing position.

          Comment


            #6
            Ok, then you would really need to run with TraceOrders to see exactly why it was cancelled.

            If you start a new strategy instance it would not take into account any previous executed trades which might be in the account, it would run through historical calculations and have a strategy position then reflecting those calcs.

            More detailed infos about all sync scenarios experienced could be see here in our online helpguide - http://www.ninjatrader.com/support/h...hlightsub=sync

            Comment


              #7
              Thank you, I will add the Traceorder feature to my strategy.

              My account has the following configuration currently:
              Immediately submit live working historical orders, Sync account position = false

              This is why I am surprised that it does not recognize my position anymore for this stock only (while it recognizes the other ones)

              Comment


                #8
                Ok, great - you will find the TraceOrders to be a really helpful tool / debug help I'm sure.

                Would you mind emailing us via Help >> Mail to Support so we could review your diagnostic log / trace files for the position pickup issues?

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                580 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                335 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                554 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                552 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X