Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitLongStop & ExitLongLimit

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

    #16
    Yes i see in column Action - "BuytoCover" limit orders, always cancelled.
    SellShort limit orders works fine and this is surprice for me, I didn't expect.

    Comment


      #17
      Originally posted by nordseven View Post
      When i'm use ExitLongStop() with ExitLongLimit(), ExitLongLimit() always have been Cancelled. Why?

      My onOrderUpdate() code:
      Code:
      [LEFT]if (myEntryOrder != null && myEntryOrder == order) {
                      if (order.OrderState == OrderState.Filled) {
                          if (myStopOrder != null) { CancelOrder(myStopOrder); }
                          if (myProfitOrder != null) { CancelOrder(myProfitOrder); }
                          myStopOrder = ExitLongStop(0, true, qty, stopPrice, "long [B][COLOR=Red]stop[/COLOR][/B]", "long position");
                          myProfitOrder = ExitLongLimit(0, true, qty, profitPrice, "long [COLOR=Red][B]target[/B][/COLOR]", "long position");
                          myEntryOrder = null;[/LEFT]
                      }
                  }
      Don't do this from OnOrderUpdate, use OnExecution instead.

      After moving this code to OnExecution, remove these lines,

      Code:
      if (myStopOrder != null) { CancelOrder(myStopOrder); }
      if (myProfitOrder != null) { CancelOrder(myProfitOrder); }
      Also recommend you use unique signal names, see changes in red above.
      Last edited by bltdavid; 02-27-2016, 11:22 AM.

      Comment


        #18
        I'm tried to use onExecution() before, but don't changing name (long stop, long profit). Now it works, thank you!

        Little question!
        If i'm move everything to onExecution() why i must remove lines
        Code:
        if (myStopOrder != null) { CancelOrder(myStopOrder); }
        if (myProfitOrder != null) { CancelOrder(myProfitOrder); }
        onExecution() do something for canceling my orders?
        Last edited by nordseven; 02-29-2016, 08:52 AM.

        Comment


          #19
          Hello nordseven,

          Glad you go that working. Can you provide more detail on what you mean on your last question?

          Comment


            #20
            Originally posted by nordseven View Post
            I'm tried to use onExecution() before, but don't changing name (long stop, long profit). Now it works, thank you!

            Little question!
            If i'm move everything to onExecution() why i must remove lines
            Code:
            if (myStopOrder != null) { CancelOrder(myStopOrder); }
            if (myProfitOrder != null) { CancelOrder(myProfitOrder); }
            onExecution() do something for canceling my orders?
            Because they should already be null. Other code elsewhere is responsible for making sure they become null.

            If they are not null at this point, inside OnExecution, you actually have a bigger problem.

            Think about it carefully: why possibly would a leftover stop or target still exist such that you need to cancel it just before submitting a new stop and target order? That's not how it (**) works.

            (**) By "it" I mean the flow of order management, or in other words: the dance between OnOrderUpdate and OnExecution and "who sets who to null, and when".

            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