Hi all, I would like to be informed when an order hits its SL or TP price specified during the OrderSend (). Which function should I use? Or which method am I called back when it happens? Please advice. Thanks.
- How to inform EA if an order is closed by hitting stop loss or take profit?
- Close all open orders when first order TP hit
- FORTS SL and TP
Loop through order history. Once a trade closes, the count of orders in orders history will increase.
hth
v
static int LastHistoryCount; if (LastHistoryCount!=OrdersHistoryTotal()) { for(int n = LastHistoryCount ; n < OrdersHistoryTotal(); n++) { OrderSelect(n, SELECT_BY_POS, MODE_HISTORY); if (OrderSymbol()==Symbol() && OrderType()<=1 && OrderMagicNumber()==magic) { // Do stuff } } } LastHistoryCount=OrdersHistoryTotal();
And in terms of the "stuff" that you'll do, this may include:
- Assume any in-scope orders which have a +ve return from OrderProfit() have triggered the TP
- Assume any in-scope orders which have a -ve return from OrderProfit() have triggered the SL
- Perform notifications as necessary using SendMail()
CB

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register