Assuming that you only send one order at a time you can continuously check whether you have open orders which are not yet filled. You can do so by using OrdersTotal(). When you order is executed and gets filled you have no more remaining open orders. This is the signal to you that you order has been executed and filled.
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
I'm writing an Expert Advisor that closes trades on his own, given a stop loss or a take profit using OrderSend.
double tp = price + point * slTpDeviation; request.tp = tp;
OrderSend(request,result)
I have a boolean variable, that depends on whether or not the agent currently has an active trade or not.
bool undergoingTrade;
When I find a condition that makes me want to close the trade I can set the boolean easily, but when the trade completes automatically, either in a profit or a loss, I am not updating the boolean.
Is there a function, that is called whenever a trade is completed?
Is there a practice programmers use to notify the EA that a trade has been completed?
Thanks in advance.