MQL4 implementation of onTrade event handler - MetaTrader 4 Expert - MT4/MT5 Resources


The code keeps track of the order's tickets in a CArrayInt way. It monitors the ticket list for changes with a timer and it fires these event handlers:
//+------------------------------------------------------------------+ //|Event handler when stop loss is hit | //+------------------------------------------------------------------+ Blank stop loss ( own ticket); //+--------------------------------------------------------------------------------+ //|Event handler when take profit is reached | //+------------------------------------------------------------------+ Blank take profit ( own ticket); //+--------------------------------------------------------------------------------+ //|Event handler when opening a new order | //+------------------------------------------------------------------+ Blank transaction input ( own ticket); //+---------------------------------------------------------------------------------+ //|Event handler when order is closed (deleted) | //+------------------------------------------------------------------+ Blank transaction exit ( own ticket);
Note : Not all features of the MQL5 onTradeTransaction handler are implemented here. This is just a basic method.
In the screenshot below you can see the EA's output log:
Attachment download
📎 ontrade.mq4 (9.23 KB)
Source: MQL5 #49474
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •