Announcement

Collapse
No announcement yet.

buyStop order is not automatically cancelled after a position is closed.

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

  • buyStop order is not automatically cancelled after a position is closed.

    Hi ,
    I am testing an EFS I created where I open a position, and then place a stop order. When I close the position, the stop order is not removed automatically, it just hangs there.

    An example of the calls I use to initiate the position is as follows (nStop and nShares are defined elsewhere):

    buyMarket(getSymbol() , nShares);
    sellStop(getSymbol() , nShares, nStopPrice);

    The position is closed using the following function call:
    closePosition(getSymbol(), nShares);

    Would anyone shed somelight on what I should do to fix this problem?

    Thanks in advance...

  • #2
    Just curious, are you using the Interactive Brokers plugin with v10.6 or V11?

    Comment


    • #3
      I am using 10.6 . I still can't figure v. 11 out.

      Comment


      • #4
        SherifT,

        I'm not sure how your EFS is configured, but have you considered added the cancelOrder function after the you've closed the position?

        We can try testing the on our side provide you'd be willing to other PM or email the EFS.

        AveryH
        eSignal Support

        Comment


        • #5
          Thank you for your response and insight. Yes I did, I added a line to cancel orders once a position is closed, the results were not satisfactory as it was not consistent in executing the order (that is another issue with paper trading I encountered where I find a lot of cancelled orders in the log without any description as to why they are cancelled - I ended up adding a delay after executing orders which reduced the number of cancellation or so I think ).

          This is the piece of code I was refering to above, where I had used cancelOrder.

          closePosition(getSymbol(), gnShares);

          // seems like the stops are not cancelled automatically, so cancel manually for now until problem is figured out
          // cancelOrder(getSymbol());

          sleep (400); // allow room for the order to be filled

          Thanks again for your response, and my apologies to taking time to reply, for some reason I don't get a notification when a reply is posted despite subscribing to the thread and checking email notification upon reply ...

          Have a great day...

          Comment


          • #6
            Further to my note below, The approach that I decided to follow is not to rely on generic broker calls - once the EFS is at an acceptable state - and use available API calls in sending bracket orders.

            For now, I added code to manage stop losses manually avoiding the process of sending stop loss orders (tedious and raw but it sort of works on short intervals). This approach also helped overcome the limit of setting stops that are out of previous bar's range - I understood it is still an outstanding issue with eSignal.

            I certainly be willing to share the code in question, if it is OK with you let me know and I will trim and cleanse the EFS in question and email to you.

            Thanks again...
            Sherif

            Comment


            • #7
              SherifT,

              Thank you for the quick reply, Which of the brokers are you using? There are a couple out there such FXCM that will not accept stoploss order via the API.

              Not being an EFS expert we can test the EFS and see if we can duplicate the issue and if so try and work towards resolve any errors. You can either post it here or email it to [email protected].

              AveryH
              eSignal Support

              Comment

              Working...
              X