Push Notification for Opened / Closed Trades (Netting)
Info
The Push Notification for Opened / Closed Trades (Netting) is a Library for MetaTrader 5 that features sends notifications for trade opens and closes shows trade type (buy/sell) and lot size for new trades displays profit/loss for closed trades works in both live trading and strategy tester (sends to logs in tester) monitors last 2 hours of trading history prevents notification spam through basic throttling installation add this function to your expert advisor (ea) or script enable push notifications in your metatrader platform: tools → options → notifications check "enable push notifications" configure metatrader mobile app on your phone important notes history window: monitors the last 2 hours of trading history can be adjusted by changing the 7200 value (in seconds)throttling: prevents excessive notifications by limiting checks to once per second can be removed by deleting the time check if needederror handling: includes basic error checking prints error messages to journal for troubleshooting common issues and solutions no notifications received: verify push notifications are enabled in mt5 check mobile app is properly configured ensure your broker allows push notificationsmissing trades: check if the 2-hour history window is sufficient increase the history window if needed (7200 seconds)duplicate notifications: this shouldn't occur due to built-in checks if it happens, verify you're not calling the function multiple times best practices call this function in your ea's ontick() function keep the metatrader mobile app installed and configured test in a demo account first monitor the experts log for any error messages.
Usage
This tool is typically used for enhancing chart analysis and decision making.
Platform
This Library works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Libraries folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Push Notification for Opened / Closed Trades (Netting)
1. Storage: Place library files in the MQL/Libraries directory to ensure they are accessible to your projects.
2. Implementation: Include the library in your code using the #import directive, ensuring you match the exact function names and parameters.
3. Compilation: Ensure the library is present in the directory before you compile your main EA or script, as the compiler links them during this phase.
4. Management: Keep libraries organized in sub-folders if you manage many custom functions to maintain a clean project structure.
Frequently Asked Questions
Q: What is a library file used for? A: Libraries store reusable code modules, allowing you to centralize common logic used by multiple EAs or indicators.
Q: Is a library executable? A: No, libraries are non-executable files containing functions; they must be imported into an EA, indicator, or script to function.
Q: Can I update a library while the platform is running? A: You should compile your EA or script after updating a library to ensure the latest code changes are integrated.
What this tool does
Features Sends notifications for trade opens and closes Shows trade type (Buy/Sell) and lot size for new trades Displays profit/loss for closed trades Works in both live trading and strategy tester (sends to logs in tester) Monitors last 2 hours of trading history Prevents notification spam through basic throttling Installation Add this function to your Expert Advisor (EA) or script Enable push notifications in your MetaTrader platform: Tools → Options → Notifications Check "Enable Push Notifications" Configure MetaTrader mobile app on your phone Important Notes History Window: Monitors the last 2 hours of trading history Can be adjusted by changing the 7200 value (in seconds)Throttling: Prevents excessive notifications by limiting checks to once per second Can be removed by deleting the time check if neededError Handling: Includes basic error checking Prints error messages to journal for troubleshooting Common Issues and Solutions No Notifications Received: Verify push notifications are enabled in MT5 Check mobile app is properly configured Ensure your broker allows push notificationsMissing Trades: Check if the 2-hour history window is sufficient Increase the history window if needed (7200 seconds)Duplicate Notifications: This shouldn't occur due to built-in checks If it happens, verify you're not calling the function multiple times Best Practices Call this function in your EA's OnTick() function Keep the MetaTrader mobile app installed and configured Test in a demo account first Monitor the Experts log for any error messages.
Typical Use Case
This Library excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Library works on MetaTrader 5. Place the file in the MQL5/Libraries folder and restart the terminal.
Description & Settings
Related: observer (push) - behavioral design pattern - another powerful library for MetaTrader 5 traders.
FeaturesSends notifications for trade opens and closes
Also recommended: MT5 to Telegram - Professional Trading Notifications Library - similar library with strong performance on MetaTrader 5.
Shows trade type (Buy/Sell) and lot size for new trades
Displays profit/loss for closed trades
Works in both live trading and strategy tester (sends to logs in tester)
Monitors last 2 hours of trading history
Prevents notification spam through basic throttling Installation
Add this function to your Expert Advisor (EA) or script
Enable push notifications in your MetaTrader platform:
Tools → Options → Notifications
Check "Enable Push Notifications"
Configure MetaTrader mobile app on your phone Important Notes
History Window
:
Monitors the last 2 hours of trading history
Can be adjusted by changing the 7200 value (in seconds)
Throttling
:
Prevents excessive notifications by limiting checks to once per second
Can be removed by deleting the time check if needed
Error Handling
:
Includes basic error checking
Prints error messages to journal for troubleshooting Common Issues and Solutions
No Notifications Received
:
Verify push notifications are enabled in MT5
Check mobile app is properly configured
Ensure your broker allows push notifications
Missing Trades
:
Check if the 2-hour history window is sufficient
Increase the history window if needed (7200 seconds)
Duplicate Notifications
:
This shouldn't occur due to built-in checks
If it happens, verify you're not calling the function multiple times Best Practices
Call this function in your EA's OnTick() function
Keep the MetaTrader mobile app installed and configured
Test in a demo account first
Monitor the Experts log for any error messages
You may also like: Chain of responsibility - behavioral design pattern - excellent alternative for library users on MetaTrader 5.
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.