Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Some Long Limit orders don't get executed

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

    Some Long Limit orders don't get executed

    I built a simple strategy based on the breakout of the previous blue area (as you can see in the chart attached).
    Calling the upper end of such congestion areas MaxRange, I put as Long Entry Condition:
    if (Position.MarketPosition == MarketPosition.Flat
    && (InTrade == false)
    && Close[0] > MaxRange)

    {
    myEntryOrder = EnterLongLimit(0, true, DefaultQuantity, MaxRange, "LongLimit");
    InTrade = true;
    barNumberOfOrder = CurrentBar;
    DrawDot("EntryLimit", true, 0, MaxRange, Color.Red);
    }

    As you can see from my 5 arrows in the chart below:
    1st arrow: the trade is taken correctly
    2nd arrow: the trade is not taken, but the Red Dot is drawn. Why the trade was not taken?
    3rd arrow: trade is not taken. Why?
    4th arrow: trade is not taken. Why?

    Thank you
    Attached Files

    #2
    stefy,

    If you get the red dot that means that code block executed and your order would have been submitted. Since you do not see the order it means something else happened in between submission to acceptance. In the other areas you do not even see the red dot. That means that code block you are in never executed which tells you that your conditions were not true at those points in time.

    What I suggest you do is use TraceOrders = true to see why your first order was either rejected or cancelled. Then you can code your strategy to account for such behavior.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I was thinking to use the Sample you provided some time ago, just I don't know which format to use for the DayOfWeek, since it's not an int value.
      I did the following, but it doesn't compile:
      startDateTime = new DateTime(Time[0].Year, Time[0].Month, DayOfWeek.Monday[0], 0, 0, 0);

      Thank you

      Comment


        #4
        Time[0] is already a DateTime object. I believe you could just do startDateTime = Time[0]. See if that works.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          startDateTime = Time[0] compiles, but then how am I supposed to add it has to start on Monday?
          If I do startDateTime=Time[0].DayOfWeek it doesn't compile anymore.
          Thank you

          Comment


            #6
            Not sure what you mean. When you make a DateTime object there is no information for storing day of week. You just give it a date. Year/Month/Day. The DayOfWeek just tells you if this said DateTime object is a Monday, Tuesday, etc.

            You would just do something like
            Code:
            if (Time[0].DayOfWeek == DayOfWeek.Monday)
                // Do something;
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              I just need to get a range with startDate (Monday, 0AM) and endDate (Friday, 12PM).
              I don't see how I can do that using the if expression as below:
              if (Time[0].DayOfWeek == DayOfWeek.Monday)
              // Do something;
              //Do something should be GetBar? How?

              Thank you

              Comment


                #8
                stefy,

                Just use GetBar() and then pass in a DateTime object consisting of a date that is Monday. Then use it 4 more times for each day of the week.

                GetBar(new DateTime(2008, 11, 10));
                GetBar(new DateTime(2008, 11, 9));
                etc.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  stefy,

                  If you get the red dot that means that code block executed and your order would have been submitted. Since you do not see the order it means something else happened in between submission to acceptance. In the other areas you do not even see the red dot. That means that code block you are in never executed which tells you that your conditions were not true at those points in time.

                  What I suggest you do is use TraceOrders = true to see why your first order was either rejected or cancelled. Then you can code your strategy to account for such behavior.
                  I did as you suggested and Traced the orders. I'm attaching the Log below.
                  As per my chart:
                  1st arrow: fine
                  2nd arrow: I see the red dot only because NT cannot execute (JUST in back test) on the same bar, so the order ends up to be executed few bars later, when the price touches that level again. Please correct me if I'm wrong
                  3rd arrow: I see NO explanation. The Log doesn't help. Nothing is going on, despite all the conditions are met, as for the previous trades.
                  4th arrow: again, nothing happens, no clue from NT.
                  I wonder if something happens internally NT (for instance, because entry and exits happen in the same bar on the 2nd arrow) and NT somehow freezes and stops to send orders at all.
                  The conditions were all met:
                  1. Close>Range (in Blue color bars)
                  2. Market Position Flat
                  3. InTrade false
                  Please help.
                  Thank you
                  Attached Files
                  Last edited by stefy; 11-12-2008, 06:05 AM.

                  Comment


                    #10
                    3 and 4. How do you know the conditions are true? Remember, computers only do exactly as they are told. If it does not fire the conditions are either not true or for some reason the code is not reaching that code block. What you want to do if you are not seeing TraceOrders is use regular Print()s. You want to print out the information for all of your conditions to determine if they are really true. Print inside the if-statement. Print outside the if-statement and then also print after the if-statement. That way you can track the code manually.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      I printed out the values, as in the file attached (Log2), but I'm getting lost.

                      3. 09/30 until 7AM MarketPosition = Flat, InTrade = True
                      Next bar (7:30AM) MarketPosition = Flat, InTrade = False and no order triggered!
                      If MarketPosition was Flat, why was InTrade = True?
                      It also doesn't make sense it changed to InTrade = False if there is no order executed.
                      4. 10/01 8:30AM MarketPosition = Flat, InTrade = False. No order triggered.
                      Attached Files

                      Comment


                        #12
                        You outlined 3 entry conditions earlier:
                        1. Close>Range (in Blue color bars)
                        2. Market Position Flat
                        3. InTrade false

                        You need to also print for your Close price and your Range to manually evaluate that > condition.

                        If you are getting MarketPosition=flat and InTrade=true then you will need to debug out your code. From the looks of this:
                        Code:
                        29/09/2008 2.30.00 Entered internal PlaceOrder() method at 29/09/2008 2.30.00: Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='LongStopLoss' FromEntrySignal='LongLimit'
                        29/09/2008 2.30.00 Long True
                        29/09/2008 3.00.00 Flat True
                        It looks like you submit a stop loss at 2:30. The stop loss is filled at 3, but you simply don't reset your InTrade variable.
                        Josh P.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        576 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        334 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
                        553 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        551 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X