This automated script is designed to act as a profit and loss monitor for specific trading positions within your MetaTrader platform. Its primary purpose is to keep you informed by sending real-time email notifications whenever a designated trade reaches a predefined financial milestone.
How the Logic Works
The tool operates by continuously scanning a specific trade (which you identify via a unique ticket number) to track its current profit or loss value. It compares this live data against two specific boundaries that you set: a "Maximum" target and a "Minimum" threshold.
1. Monitoring the Maximum Target If the trade's profit rises to meet or exceed your specified maximum limit, the script performs two actions:
- It triggers an automatic email notification containing the name of the asset (symbol) and the exact profit amount reached.
- It creates a "one-time" trigger, ensuring that you only receive this specific alert once per trade cycle to avoid being flooded with repeated emails as the price fluctuates.
2. Monitoring the Minimum Threshold Similarly, the script watches for the trade's value to drop to or below your specified minimum limit (representing a loss threshold). When this occurs:
- It immediately sends an email alert notifying you of the asset name and the current value.
- Like the maximum trigger, it is programmed to send this notification only once per trade cycle.
Summary of User Experience
Instead of manually watching the charts at all times, this script allows you to stay informed remotely. It serves as a digital "alarm system" that alerts you the moment your trading goals are met or when a trade hits a critical point that requires your attention, providing you with peace of mind and timely information directly in your inbox.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
extern int Order;
extern int Max;
extern int Min;
int isMax,isMin;
int init(){return(0);}
int deinit(){return(0);}
int start() {
OrderSelect(Order, SELECT_BY_TICKET);
int p=OrderProfit();
if(p>=Max && isMax==0) {
isMax=1;
SendMail(OrderSymbol()+" maximum reached: "+p,"");
}
if(p<=Min && isMin==0) {
SendMail(OrderSymbol()+" minimum reached: "+p,"");
isMin=1;
}
}
Comments