No, OnTrade() doesn't work with MT4.
GlobalVariables of the terminal, file, custom events...
how i solution it
int totalOrders = OrdersTotal();
void OnTick(){
//void OnTradeGambiarra(){
if(totalOrders != OrdersTotal()){
//+-----------
//Ur CODE HERE
totalOrders = OrdersTotal();
}
//}
}
William Roeder #:
Not really. Triggers if an order opens or closes on any chart. Does not trigger if a pending order opens.
Thank you for the correction, I got it. Because the number of orders did not change when it was still pending vs when it was open position.
If we have to calculate the total number of pending orders using looping will slow down the system.
Means to deal with sub -programs related to pending orders will be more efficient using OnTimer.

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
OnTrade() operates in mql4?
Accustomed to mql5, I see that does not work in mql4... It's like that?