Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitLongStop not working

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

    ExitLongStop not working

    I have an initial StopLoss

    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    Add(PeriodType.Minute, 5);
    SetStopLoss(450);
    MP = new DataSeries(this);
    TT = new DataSeries(this);
    PosLow = new DataSeries(this);
    }

    and I have a trailing stop (highlighted in orange) but the Trailing Stop does not work? Cant figure out why?

    // ///////////////////////
    // Trailing Stop Long
    // ///////////////////////

    if (Position.MarketPosition == MarketPosition.Long)
    {
    MyATRCalc = ATR(14)[0]*atr5min_trail_mult_long;
    if ((TT[0] != TT[1]) || (MP[1] != 1))
    {
    PosLow[0] = Low[0] - MyATRCalc;
    }
    PosLow[0] = Math.Max(PosLow[1], (Low[0]-MyATRCalc));
    DrawDot("TStop_Long"+ CurrentBar, true, 0, PosLow[0], Color.Orange);

    }
    ExitLongStop(PosLow[0]);
    Attached Files

    #2
    Seems to be getting stopped out by the StopLoss and not by the Trailing Stop (orange dots)?

    Comment


      #3
      mefTrader, please work with TraceOrders = true in your Initialize() to debug your order behavior, likely you're running into the Internal Order Handling Rules here -

      http://www.ninjatrader-support.com/H...verview36.html (botton section).

      Comment


        #4
        Why cant a StopLoss and ExitLong not exist as 2 seperate stops

        Methods that generate orders to exit a position will be ignored if a strategy position is open and:
        • An order submitted by an enter method (EnterLongLimit() for example) is active and this entry order is used to open a position in the opposite direction
        • An order submitted by a set method (SetStopLoss() for example) is active



        I am trying to use an ExitLong in parallel with a StopLoss... I am bring ing code over from Tradestation where this worked and I dont understand why these could not co-exist?


        The stop that is closer to the price action should be active - strategy calculations should know this ahead if there is a clear distinction??


        Whats the workaround here?

        Comment


          #5
          How can I integrate a Currency StopLoss and a Price Stop into StopLoss() ? Any examples out there?

          Comment


            #6
            mefTrader, the order handling rules are there to protect you and your strategy of unwanted positions / inflight executions - thus if the SetStopLoss is active other Exit's will be ignored.

            You could work here by adjusting the price level of your stop order as needed.

            Unfortunately you can't have a currency and price based stop running on the same position with SetStopLoss().

            With NinjaTrader 7 we also offer a new unmanaged order submission mode, which gives you the freedom to manage / code all on your own and 'neutralizing' the order entry rules discussed.

            Comment


              #7
              ok how do I get more information about "a new unmanaged order submission mode, which gives you the freedom to manage / code all on your own and 'neutralizing' the order entry rules discussed." ?

              Comment


                #8
                ok read http://www.ninjatrader.com/support/h...d_approach.htm

                Sounds like using a sledgehammer to something that should be available a SetStopLoss() to work in parallel to TrailingStop() . Since NT7 ins still in beta could this be addressed? (wrt to below)??


                The SetStopLoss() method can NOT be used concurrently with the SetTrailStop() method for the same position, if both methods are called for the same position (fromEntrySignal) the SetStopLoss() will always take precedence. You can however, use both methods in the same strategy if they reference different signal names.

                Comment


                  #9
                  Ok this works folks for future reference


                  // ///////////////////////
                  // Trailing Stop Long
                  // ///////////////////////
                  if (Position.MarketPosition == MarketPosition.Flat)
                  {
                  SetStopLoss(450);
                  }

                  if (Position.MarketPosition == MarketPosition.Long)
                  {
                  MyATRCalc = ATR(14)[0]*atr5min_trail_mult_long;
                  if ((TT[0] != TT[1]) || (MP[1] != 1))
                  {
                  PosLow[0] = Low[0] - MyATRCalc;
                  }
                  PosLow[0] = Math.Max(PosLow[1], (Low[0]-MyATRCalc));
                  DrawDot("TStop_Long"+ CurrentBar, true, 0, PosLow[0], Color.Orange);
                  if ((Position.AvgPrice - PosLow[0]) * 10 < 450)
                  {
                  SetStopLoss(CalculationMode.Price, PosLow[0]);
                  }
                  }

                  Comment


                    #10
                    *10 multiplier is because I am tradin the Russell (@TF)

                    Comment

                    Latest Posts

                    Collapse

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