Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order Exit Problem

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

    Order Exit Problem

    I am having a problem with orders not respecting my stop and profit targets. Please see the attachment. In it you will see 4 trades for 12-1-2011 trading ES 12-11. I am OK with the first 2 trades but the second 2 are not doing what I expect.

    Very simply, the stop target is 6 ticks and the profit target is 4 ticks. However, the first problematic trade (3rd trade in log, timestamp: 4:47:xx) is exiting via a market order with just a 1 tick gain. It enters short at 1244.75 and exits at 1244.50.

    The second problem trade (4th in log, timestamp: 4:54:xx) is exiting with a 1 tick loss. It enters short at 1244.00 and exits at 1244.25.

    My SetStopLoss and SetProfitTarget statements never change in the strategy: always a profit of 4 ticks and a stop of 6 ticks using only limit orders.

    Can someone tell from the TraceOrders log (attachment) what the problem is? Please let me know if I can provide any additional information.
    Attached Files

    #2
    Originally posted by scottreynolds View Post
    I am having a problem with orders not respecting my stop and profit targets. Please see the attachment. In it you will see 4 trades for 12-1-2011 trading ES 12-11. I am OK with the first 2 trades but the second 2 are not doing what I expect.

    Very simply, the stop target is 6 ticks and the profit target is 4 ticks. However, the first problematic trade (3rd trade in log, timestamp: 4:47:xx) is exiting via a market order with just a 1 tick gain. It enters short at 1244.75 and exits at 1244.50.

    The second problem trade (4th in log, timestamp: 4:54:xx) is exiting with a 1 tick loss. It enters short at 1244.00 and exits at 1244.25.

    My SetStopLoss and SetProfitTarget statements never change in the strategy: always a profit of 4 ticks and a stop of 6 ticks using only limit orders.

    Can someone tell from the TraceOrders log (attachment) what the problem is? Please let me know if I can provide any additional information.
    In what event handler are your SetStopLoss and SetProfitTarget located?

    Comment


      #3
      They are set in OnBarUpdate right before the trade is taken. Here is the long entry:

      Code:
      							if (((bTakeHistorical && Historical) || !Historical)) {
      								SetProfitTarget(sENTRY1L, CalculationMode.Ticks, ProfitTarget);
      								SetProfitTarget(sENTRY1S, CalculationMode.Ticks, ProfitTarget);
      								SetStopLoss(CalculationMode.Ticks, StopLoss);
      
      								if (iOrderType == eOrderType.MARKET) {
      									iOrderL1 = EnterLong(iQuantity1, sENTRY1L);
      								}
      								else if (iOrderType == eOrderType.BID_ASK) {
      									tVars.lEntry = GetCurrentBid();
      									iOrderL1 = EnterLongLimit(0, true, iQuantity1, tVars.lEntry, sENTRY1L);
      								}
      								else if (iOrderType == eOrderType.LIMIT) {
      									tVars.lEntry = Close[0] - iLimitOffsetTicks * TickSize;
      									iOrderL1 = EnterLongLimit(0, true, iQuantity1, tVars.lEntry, sENTRY1L);
      								}
      							}

      Comment


        #4
        They are set in OnBarUpdate ...
        In that case you must reset them when the strategy goes flat.
        Last edited by koganam; 12-11-2011, 08:28 PM.

        Comment


          #5
          OK, I can certainly try that - can you tell me the rationale for that? I have never seen anything in the documentation or samples that indicate this is a requirement.

          Comment


            #6
            Originally posted by scottreynolds View Post
            OK, I can certainly try that - can you tell me the rationale for that? I have never seen anything in the documentation or samples that indicate this is a requirement.
            ref: http://www.ninjatrader.com/support/h...etstoploss.htm

            Look at the 3rd bulleted point. It certainly says so there in plain language.

            Comment


              #7
              Thanks for the link in the documentation. I used to call SetStopLoss and SetProfitTarget just once in Initialize() and that was giving me the same problem and that's when I decided to move them to OnBarUpdate. And according to the link you sent, it should not be required to call them again. In this particular strategy I'm working on, the targets never change.

              Comment


                #8
                Right, once set you do not need to change if your value is static.

                Let me know if I can be of further assistance.
                BrettNinjaTrader Product Management

                Comment


                  #9
                  I have a similar problem:

                  I set both StopLoss & ProfitTarget in Initialize() only. Nothing is changed later on.

                  However, sometimes I do not see StopLoss Order in Control Panel. It simply just not placed... I assume there is something terribly wrong I am doing because I do not dare to think that StoLoss functionalitymay be broken...

                  Could anyone give an idea?..

                  By the way - is there any min limit for stop loss, like not closer than X ticks to entry?

                  Thank you!

                  Comment


                    #10
                    Hi alex.nt,

                    Would TraceOrders output shed any light on why the order is not submitted? It could be ignored if you had other working exits, for example.

                    The smallest unit you could submit a stop loss is 1 tick, although the closer you are to the market, the higher the chance this order could be rejected immediately upon submission.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Eh... would you mind to give a bit more details regarding "the closer you are to the market, the higher the chance this order could be rejected immediately upon submission".

                      Do you mean that the price will go through the stop loss mark before the order would have a chance to get filled? Shouldn't it just fill by market then?

                      I mean it is quite harsh to find out that the order that guards you from losses has been rejected....

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      668 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      377 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
                      575 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