Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Protective Stop Orders Not Being Sent

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

    Protective Stop Orders Not Being Sent

    Would someone be able to suggest to me why my stop orders are not being placed when I execute a long position please? The stop orders are working fine when a short position is executed and the code - as far as i can see - is identical.

    entryOrderL/entryOrderS are the IO entry order tags for Long and Short positions respectivel
    stopOrderL/stopOrderS are the protective stop orders for long and short position respectively
    StopLevelL/StopLevelS are doubles that store specific price levels to enter the protective stop order and are stored when the entry signal is triggered.

    Any suggestions would be much appreciated.

    Mark


    protected override void OnExecution(IExecution execution)
    {


    // Long Execution Stop
    if (entryOrderL != null && entryOrderL.Token == execution.Order.Token)
    {

    if (execution.Order.OrderState == OrderState.Filled)
    {
    // Long Stop at low of signal
    stopOrderL = ExitLongStop(0, true, 1, StoplevelL, "stop", "long entry");


    // Resets the entryOrder object to null after the order has been filled
    if (execution.Order.OrderState != OrderState.PartFilled)
    {
    entryOrderL = null;
    }
    }
    }


    // Short execution stop
    if (entryOrderS != null && entryOrderS.Token == execution.Order.Token)
    {

    if (execution.Order.OrderState == OrderState.Filled)
    {


    // Short Stop
    stopOrderS = ExitShortStop(0, true, 1, StoplevelS, "stop", "Short entry");

    if (execution.Order.OrderState != OrderState.PartFilled)
    {
    entryOrderS = null;
    }
    }

    #2
    Check your code where you set StoplevelL.

    Comment


      #3
      Hi

      Thanks. I had checked and it seems fine.


      {
      entryOrderL = EnterLongStop(0, true, 1, High[0] + 5 * TickSize, "Long entry");
      StoplevelL = MIN ((Low), 2)[0] - (5 * TickSize);
      }

      {
      entryOrderS = EnterShortStop(0, true, 1, Low[0] - 5 * TickSize, "Short entry");
      StoplevelS = MAX ((High), 2)[0] + (5 * TickSize);
      }
      The wierd thing is I set up the long side first and it was working fine. I then set-up the short side by using the same code and swapping things around and now only short side works! Puzzling....

      Comment


        #4
        Sounds like your short is cancelling your long.

        Comment


          #5
          MJUK05, please set TraceOrders = true in the Initialize() section to see why orders are not being sent or are being canceled.
          AustinNinjaTrader Customer Service

          Comment


            #6
            wont compile thread

            Hello ninja trader austin i was wondering if you could take a look at my wont compile thread to tell me what I am doing wrong? many thanks James

            Comment


              #7
              James, I am currently wading my way through all the support tickets. Since yours is the most recent, I will get there last. We look at all threads, so asking us to look at your thread isn't necessary.

              EDIT: I now see you have multiple tickets open. I'll answer them as I get to them.
              AustinNinjaTrader Customer Service

              Comment


                #8
                many thanks!

                Thanks for the reply Austin,

                I am new to this area so I am keen to learn! Speak to you soon!

                James

                Comment


                  #9
                  Originally posted by Sleeping Troll View Post
                  Sounds like your short is cancelling your long.

                  I don't think so. I did not post it as it appears in the strategy. I just cut both snippets of code. They both have different IF entry criteria i.e. entryOrder(short or long) != null so should be working at different times.

                  Austin - thanks i'll give it a go.

                  Cheers

                  Mark

                  Comment


                    #10
                    In one place you use lower case to label the signal (i.e. "long entry"):

                    Code:
                    stopOrderL = ExitLongStop(0, true, 1, StoplevelL, "stop", "long entry");

                    In the other, you use upper case (i.e. "Long entry"):

                    Code:
                    entryOrderL = EnterLongStop(0, true, 1, High[0] + 5 * TickSize, "Long entry");
                    Try making the two consistent.

                    Comment


                      #11
                      Anothertrader

                      Thanks - good spot.

                      Now the shorts don't trigger but the longs are working as they should.

                      On to solving the next problem!

                      Cheers

                      Mark

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      647 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      369 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      108 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      572 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      573 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X