Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limit order ignored

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

    Limit order ignored

    I lost money on a strategy I expected to win with today, and I am trying to understand how that is possible. Here is the situation:

    I am looking at turning points: i.e.:
    if (MyInd[0] > MyInd[1] && MyInd[1] <= MyInd[2])
    EnterLongLimit(100,Close[0]-10*TickSize);
    if (MyInd[0] < MyInd[1] && MyInd[1] >= MyInd[2])
    EnterShortLimit(100,Close[0]+10*TickSize);

    SetTrailStop(CalculationMode.Percent,0.05);

    My strategy executes on 30-min bar closes.
    Sequence:
    9:30 MyInd = 142.31
    10:00 MyInd = 142.30 result: 10:00:01 enters short limit that executes that second!
    10:30 MyInd = 142.34 result: should enter limit order to go long, but NOTHING HAPPENS!
    11:00 MyInd = 142.40

    Price definitely went well through where the limit order should have been entered on the next bar.
    So, now I am short 100 shares of this stock when I should be long, and what should be a winning day becomes a losing one.

    What happened?
    1. The trace and log show that the trailing stop was updated on the 10:30 bar (they are never updated in real-time, contrary to the documentation).
    2. No evidence of an EnterLongLimit order exists in either trace or log!

    Net result: I lose real money.

    How do I avoid this? I will implement whatever programming I have to in order to fix this logic - I am an expert programmer - but it is unclear from the documentation why this should have failed.

    Please answer the following:

    1. Does the existence of a stoploss order break any strategy with limit orders that trade both directions?
    2. If I modify the code to the following should it absolutely fix this?
    if (MyInd[0] > MyInd[1] && MyInd[1] <= MyInd[2])
    {
    if (Position.MarketPosition == MarketPosition.Short)
    {
    ExitShort();
    }
    EnterLongLimit(100,Close[0]-10*TickSize);
    }

    I should do this anyway to ensure an exit, but will it also place the long limit entry order?

    #2
    Hi zstheorist, did you use TraceOrders = true in your strategy Initialize() to debug this? Most likely you're hitting the 'Internal Order Handling Rules' as outlined here - http://www.ninjatrader-support.com/H...verview36.html

    Your mentioned workaround should place the long limit entry order if conditions are hit, as the Set method is cancelled when you close the trade with ExitShort().

    Comment


      #3
      Always check the LOG tab when things don't seem right.
      mrlogik
      NinjaTrader Ecosystem Vendor - Purelogik Trading

      Comment


        #4
        Will do

        (Un)fortunately the situation that occurred is rare, so the workaround I've implemented for now is to:

        if (Position.MarketPosition == MarketPosition.Short)
        EnterLong(100);
        else
        EnterLong(100,Close[0]-10*TickSize);

        This is supposed to bypass those rules. I mentioned I had read them, but they were confusingly written. Reading between the lines of your response, the answer to my first question is: You cannot run a strategy with limit orders and stops only that trades both directions. Now that I know, I will work around it. I was trying to get prepared for the next round of up-tick rules. Market orders are a small price to pay in this strategy, it just removes some more complicated ideas I had from consideration.

        I may try out my first workaround in the future:
        if (Position.MarketPosition == MarketPosition.Short)
        ExitShort();
        EnterLong(100,Close[0]-10*TickSize);

        For the benefit of newer users (I am not new, I just was trading futures with market orders before), it would really be helpful if you could have a clear example of a correctly constructed entry/exit strategy that obeys the rules. Take an SMA cross for example, just to make it simple. Explain precisely why if you have a stop, a limit order in the opposite direction is ignored, and demonstrate possible ways of getting around that.
        This would go a LONG way to clarifying the gaps - we could all "USE THE SOURCE, LUKE!"

        Thanks

        Comment


          #5
          Thank you for the input and feedback, we're constantly working on evolving our available tutorials and training material.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          80 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          46 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          29 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          32 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          66 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X