AccountMonitor
Download scriptThis script functions as an automated account reporting tool designed to provide you with real-time snapshots of your trading performance. Rather than executing trades or making investment decisions, its primary role is to act as a digital monitor that summarizes your current financial standing and active positions.
How the System Operates
The logic follows a structured sequence to ensure you receive consistent updates without being overwhelmed by constant notifications:
1. Time-Based Execution The tool is designed to be "smart" about when it sends information. It identifies the start of a new price candle (a specific time interval on your chart). By recognizing these transitions, the script ensures that it performs its check at regular intervals rather than sending a notification every second, which keeps your inbox organized and manageable.
2. Portfolio Analysis Once triggered by a new time interval, the script scans your entire trading account. It specifically looks for:
- Account Health: It retrieves your current Balance (total funds) and your Equity (the actual value of your account including floating profits or losses).
- Active Positions: It identifies every open trade currently running on your account.
- Individual Performance: For every open trade, it captures whether the position is a "Buy" or a "Sell," which specific currency pair or asset it belongs to, and exactly how much profit or loss that specific trade is currently generating.
3. Automated Reporting After gathering all this data, the script compiles it into a single, readable summary message. This message includes a timestamp so you know exactly when the snapshot was taken, followed by your total account values and a detailed list of your open orders.
4. Delivery Method Finally, the tool automatically sends this summarized report to your registered email address. It labels the email as an "Account Update," allowing you to quickly glance at your portfolio status from any device without needing to have the trading platform open in front of you.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| AccountMonitor.mq4 |
//| Kirk Sloan |
//| ksfx@kc.rr.com |
//+------------------------------------------------------------------+
#property copyright "Kirk Sloan"
#property link "ksfx@kc.rr.com"
//---- input parameters
extern bool Run=true;
double Balance;
double Equity;
string Message;
datetime Bartime;
int Bartick=0;
bool Tradeallowed=true;
string Orders;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if(Bartime!=Time[0]){
Bartime=Time[0];
Tradeallowed=true;
}
if(Tradeallowed && Run == true) {
Tradeallowed = false;
Orders="";
Message = "";
OrderInfo();
Message = StringConcatenate (TimeToStr(CurTime(),TIME_MINUTES),": Balance= ",AccountBalance()," - Equity= ",AccountEquity()," - Open orders: ",Orders) ;
SendMail("Account Update", Message);
}
//----
return(0);
}
//+------------------------------------------------------------------+
int OrderInfo(){
int atotal =OrdersTotal();
int acnt;
for(acnt=0;acnt<atotal;acnt++){
OrderSelect(acnt, SELECT_BY_POS, MODE_TRADES);
if (OrderType()==OP_BUY)
Orders = StringConcatenate (Orders,"BUY ",OrderSymbol(),": Profit= ",OrderProfit()," | ");
if (OrderType()==OP_SELL)
Orders = StringConcatenate (Orders,"SELL ",OrderSymbol(),": Profit= ",OrderProfit()," | ");
}
}
Comments