How to find if any EA order has been closed by TP
Page 1 of 614 123 ... LastLast
Results 1 to 10 of 38

Thread: How to find if any EA order has been closed by TP

  1. #1
    Men I try to code my EA after one order was closed by TP to shut all of the remaining orders and start over again. Because this EA is dominated on martingale but it opens in both directions orders. If someone can help it will be much appreciated.

  2. #2
    Quote Originally Posted by ;
    indiors of what is suitable for currencies AUD / USD and NZD / USD?
    Yoo have posted in wrong loion you post in this forum the discussion will be about automated trading.

  3. #3
    Don't know whether it's valid for all brokers, but will loe [tp] in the comment / within this comment

  4. #4
    Quote Originally Posted by ;
    don't know if it's valid for many brokers, but will find [tp] from the comment / as part of this comment
    It is an option but I am not so experienced in coding. I han an advice to count each of send order after count all available orders and also compare them if they disagree then close all of the rest orders. If you can provide any help in coding this I will be very greatful.

  5. #5
    You have to look for the TPed position at the OrderHistory
    However, to be on the save side, your set of rankings must have something in common
    You can always use a new unique magicnumber to identify transactions which are belonging together and search for a trade with the same magic in History where there is [tp] in the remark
    Another way would be to utilize the Comment Field itself
    the very first trade does not have a remark and all next positions are holding the ticket quantity of standing #1 in the remark field
    So now you can look for either a closed position at which the ticketnumber matches the amount in the remark of your open positions or for a closed position where the comment contains the same amount as your open positions
    Not a simple task for a newbie developer

  6. #6
    Quote Originally Posted by ;
    you must search for the TPed position at the OrderHistory But to be on the other hand, your pair of rankings should have something in common You could always use a new unique magicnumber to identify transactions which are belonging together and search for a transaction with the exact same magic in History where there is [tp] from the comment Another way is to utilize the Comment Field itself The very first trade does not possess a comment and all following positions are holding the ticket number of standing #1 in the comment area So you can now search for either a closed position...
    I shall give a try and send the code and if you're able to find some time to correct it.

  7. #7
    https://www.nigeriaforextrading.com/...2082760502.mq4

    Hello iwjw,

    this is what I triumphed to code but still requires too much effort any help will be appreciated.

  8. #8
    I would try like code below (note code not tested).
    What the code does: It collects all order tickets from the order queue. On a tick it checks the collected tickets for if any has gone to history; if so it checks for tp closeness; if therefore that it deletes / closes all orders precisely the same emblem and same way. Then it again collects all tickets and so forth. .

    Inserted Code // distorted by // copyleft #property strict int tickets#91;#93;; int OnInit() OnTick(); reunite INIT_SUCCEEDED; void OnTick() // test orders status for(int I = 0; t lt; ArraySize(tickets); I ) if(OrderSelect(tickets#91;I#93;, SELECT_BY_TICKET, MODE_HISTORY)) // check tp hit if(OrderType() == OP_BUY? OrderClosePrice() gt;= OrderTakeProfit(): OrderClosePrice() lt;= OrderTakeProfit()) // close or delete all of same logo same leadership string symbol = OrderSymbol(); int type = OrderType(); for(int j = OrdersTotal() - 1; j gt;= 0; j--) OrderSelect(j, SELECT_BY_POS); if(OrderSymbol() == symbol) if(OrderType() gt; type two ) OrderDelete(OrderTicket()); else if(OrderType() == type) OrderClose(OrderTicket(), OrderLots(), type == OP_BUY? Bid: Ask, 1); split; // done // gather orders ArrayResize(tickets, OrdersTotal()); for(int I = 0; t lt; OrdersTotal(); I ) OrderSelect(I, SELECT_BY_POS); tickets#91;I#93; = OrderTicket();

  9. #9
    Quote Originally Posted by ;
    I would try such as code below (notice code not tested). What the code does: It collects all order tickets from the order queue. On a tick it assesses the accumulated tickets to get if any has gone to history; if so it checks for tp proximity; even if so it deletes / closes all orders in same symbol exactly the same way. Subsequently all tickets hastens and so forth. . // twisted by rockit // copyleft #property strict int tickets[]; int OnInit() OnTick(); return INIT_SUCCEEDED; void OnTick() { // check orders status for(int I = 0; t lt; ArraySize(tickets); I )...
    Mate thks for helping could you tell me exactly what to change from the code in conclusion in order to delete each of the open transactions no matter the direction. As I could see I need just to eliminate else if and let if(OrderType() == kind ) OrderClose(OrderTicket(), OrderLots(), type == 0? Ask: Bid, 1); fix?

    Also can it be possible that you show me the way to add this code from the original file that I have delivered in order to avoid if there'll be any already defined variables. I really would love that.

  10. #10
    Be aware that code as supplied above just takes into account negative slippage on TP, but not favorable slippage.
    For take account of pos. slip. An individual would have to define a tolerance value for how much better than TP would depend as TP hit.
    Or, if you want to be bold on it, you merely check if near price was above open price for buy orders, or below open price for sell orders, i.e.:
    Inserted Code // TP hit? If(OrderType() == OP_BUY() ? ) OrderClosePrice() gt; OrderOpenPrice(): OrderClosePrice() lt; OrderOpenPrice()) // yes
    Quote Originally Posted by ;
    let me know exactly what to change in the code in conclusion in order to delete all of the open trades no matter the management
    Inserted Code // close all pending functioning if(OrderType() gt; 1) OrderDelete(OrderTicket()); otherwise OrderClose(OrderTicket(), OrderLots(), kind == OP_BUY? Bid: Ask, 1);
    I shall start looking into your code once I have time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.