Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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?

    BertrandNinjaTrader Customer Service

    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.

        BertrandNinjaTrader Customer Service

        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
            BertrandNinjaTrader Customer Service

            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?
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jxs_xrj, 01-12-2020, 09:49 AM
                4 responses
                3,282 views
                1 like
                Last Post jgualdronc  
                Started by Option Whisperer, Today, 09:55 AM
                0 responses
                5 views
                0 likes
                Last Post Option Whisperer  
                Started by geddyisodin, 04-25-2024, 05:20 AM
                8 responses
                58 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by halgo_boulder, 04-20-2024, 08:44 AM
                2 responses
                22 views
                0 likes
                Last Post halgo_boulder  
                Started by mishhh, 05-25-2010, 08:54 AM
                19 responses
                6,189 views
                0 likes
                Last Post rene69851  
                Working...
                X