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.
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.
Yoo have posted in wrong loion you post in this forum the discussion will be about automated trading.Originally Posted by ;
Don't know whether it's valid for all brokers, but will loe [tp] in the comment / within 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.Originally Posted by ;
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
I shall give a try and send the code and if you're able to find some time to correct it.Originally Posted by ;
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.
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();
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?Originally Posted by ;
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.
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
Inserted Code // close all pending functioning if(OrderType() gt; 1) OrderDelete(OrderTicket()); otherwise OrderClose(OrderTicket(), OrderLots(), kind == OP_BUY? Bid: Ask, 1);Originally Posted by ;
I shall start looking into your code once I have time.