VIC_Currency_Manager
Download scriptOverview of the VIC Currency Manager
The VIC Currency Manager is a specialized dashboard tool designed for the MetaTrader 4 platform. Its primary purpose is to provide traders with a real-time, visual summary of their account status and active trading positions directly on the chart interface. Instead of requiring a trader to navigate through multiple sub-menus, this script aggregates vital data into a single, organized information panel.
Key Functional Components
Dynamic Visual Dashboard The script automatically generates a structured display on your trading screen. It creates distinct sections for "Global Information," "Historical Information," and "EA Information." This layout is designed to be clean and readable, using specific text colors and spacing to help traders quickly identify different categories of data at a glance.
Account Health & Performance Tracking The tool performs continuous calculations to monitor the overall health of the trading account:
- Equity and Drawdown: It calculates your current Equity as a percentage of your Account Balance. It specifically monitors "Drawdown" (the decline from your peak balance) and displays this as a percentage, helping traders stay aware of risk levels.
- Account Specifications: It automatically identifies your account type (such as Mini or Standard), your current leverage, and the specific server you are connected to.
Live Order Monitoring The script scans all active trades and pending orders to provide a breakdown of your current market exposure:
- Position Breakdown: It counts and displays the total number of Buy positions, Sell positions, and Pending orders currently held.
- Floating Profit/Loss: It calculates the real-time profit or loss from all open trades, including any swap fees, providing a consolidated dollar amount of your current floating gains or losses.
Intelligent Management Features To assist with organized trading, the script includes several sophisticated filtering logic points:
- Unique Identifier Tracking (Magic Numbers): The tool identifies and lists "Magic Numbers"—unique IDs used to distinguish between different automated trading systems. It specifically looks for unique active numbers so that a trader can see exactly which automated robots are currently running.
- Automated Cleanup: To ensure the trading platform remains fast and organized, the script includes a cleanup routine. When you remove the tool from your chart, it automatically deletes all the text labels and visual objects it created, leaving your workspace clean.
Summary for the User
Think of this script as a "Control Tower" for your trading account. It takes the raw data provided by your broker and transforms it into a clear, live-updating scoreboard. It tells you how much money is currently at risk, what type of account you are running, and exactly how many trades are open across all your different automated strategies simultaneously.
//+------------------------------------------------------------------+
//| VIC Currency Manager.mq4 |
//| Copyright © 2007 |
//| http://www.automatedtradingmastery.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007"
#property link "http://www.automatedtradingmastery.com"
extern int viewmode=1; //1=global Info
int acc=1;
int accobj;
double MN_Array[100];
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
ObjectCreate("VCC_Title", OBJ_LABEL, 0, 0, 0);
ObjectSet("VCC_Title", OBJPROP_XDISTANCE, 210);
ObjectSet("VCC_Title", OBJPROP_YDISTANCE, 0);
ObjectSetText("VCC_Title", "MT4-Currency Manager V1.0", 13, "Verdana", Yellow);
createRec(8,250,1,Yellow,acc,210,19);acc++;
if(viewmode==1){
createRec(8,5,30,Red,acc,220,40);acc++;
createRec(8,5,30,Red,acc,440,40);acc++;
createText("Global Information",11,White,acc,5,40);acc++;
createText("Historical Information",10,White,acc,235,40);acc++;
createText("EA Information",10,White,acc,455,40);acc++;
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
accobj=acc;
for(int index1=0;index1<=100;index1++){
MN_Array[index1]=999999999999;
}
if(viewmode==1){
double AccPercentage=(AccountEquity()/AccountBalance())*100;
double currentDD=100-AccPercentage;
createText("Server = "+AccountServer(),9,White,accobj,5,60);accobj++;
createText("Account Type = "+detectAccType(),9,White,accobj,5,75);accobj++;
createText("Leverage = 1:"+AccountLeverage(),9,White,accobj,5,90);accobj++;
createText("Total Active Order = "+TotalTrade(0,0,""),9,White,accobj,5,105);accobj++;
createText("Total BUY Position = "+TotalTrade(1,0,""),9,White,accobj,5,120);accobj++;
createText("Total SELL Position = "+TotalTrade(2,0,""),9,White,accobj,5,135);accobj++;
createText("Total PENDING Position = "+TotalTrade(3,0,""),9,White,accobj,5,150);accobj++;
createText("Total Floating P/L = $"+DoubleToStr(TotalProfit(0,""),2),9,White,accobj,5,165);accobj++;
if(currentDD>0){
createText("Current DD (%)="+DoubleToStr(currentDD,2)+"%",9,White,accobj,5,180);accobj++;
}else{
createText("Current Profit (%)="+DoubleToStr(currentDD*(0.0-1.0),2)+"%",9,White,accobj,5,180);accobj++;
}
createText("Equity (%)="+DoubleToStr(AccPercentage,2)+"%",9,White,accobj,5,195);accobj++;
createText("Active Magic Number:",9,White,accobj,5,210);accobj++;
findMagicNumber(5,225);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
string buff_str = "";
for(int i=ObjectsTotal()-1;i>=0;i--){
buff_str = ObjectName(i);
if(StringFind(buff_str,"VCC_",0)==0) ObjectDelete(buff_str);
}
//----
return(0);
}
void createRec(int fontsize,int width,int height,color c,int curobj,int XPOS,int YPOS){
string buffstr="VCC_OBJ_"+curobj;
for (int tempIDX_Y=0;tempIDX_Y<height;tempIDX_Y++){
for (int tempIDX = 0; tempIDX <= width; tempIDX++) {
ObjectCreate(buffstr + DoubleToStr(tempIDX, 0)+DoubleToStr(tempIDX_Y, 0), OBJ_LABEL, 0, 0, 0, 0, 0, 0, 0);
ObjectSetText(buffstr + DoubleToStr(tempIDX, 0)+DoubleToStr(tempIDX_Y, 0), "|", fontsize, "Times New Roman", c);
ObjectSet(buffstr + DoubleToStr(tempIDX, 0)+DoubleToStr(tempIDX_Y, 0), OBJPROP_XDISTANCE, tempIDX+XPOS);
ObjectSet(buffstr + DoubleToStr(tempIDX, 0)+DoubleToStr(tempIDX_Y, 0), OBJPROP_YDISTANCE, YPOS);
}
YPOS+=fontsize;
}
}
void createText(string content,int fontsize,color c,int curobj,int XPOS,int YPOS){
string buffstr="VCC_OBJ_"+curobj;
ObjectCreate(buffstr, OBJ_LABEL, 0, 0, 0, 0, 0, 0, 0);
ObjectSetText(buffstr, content, fontsize, "Times New Roman", c);
ObjectSet(buffstr, OBJPROP_XDISTANCE, XPOS);
ObjectSet(buffstr, OBJPROP_YDISTANCE, YPOS);
}
string detectAccType(){
string AccountType;
int AccType=MarketInfo(Symbol(), MODE_LOTSIZE) ;
if(AccType==10000){
AccountType="Mini Account";
}
if(AccType==100000){
AccountType="Standard Account";
}
if(AccType!=100000&&AccType!=10000){
AccountType="<cannot detect>";
}
return(AccountType);
}
int TotalTrade(int mode,int magicNumber,string pairSymbol) {
/*
mode 0: ALL
mode 1: BUY
mode 2: SELL
mode 3: PENDING ORDER
*/
int totalOrder = 0;
for (int index1 = 0; index1 < OrdersTotal(); index1++) {
OrderSelect(index1, SELECT_BY_POS, MODE_TRADES);
if(pairSymbol==""){
if(magicNumber==0){
totalOrder=subTotalOrder(mode,totalOrder);
}else{
if (OrderMagicNumber() == magicNumber){
totalOrder=subTotalOrder(mode,totalOrder);
}
}
}else{
if(OrderSymbol()==pairSymbol){
if(magicNumber==0){
totalOrder=subTotalOrder(mode,totalOrder);
}else{
if (OrderMagicNumber() == magicNumber){
totalOrder=subTotalOrder(mode,totalOrder);
}
}
}
}
}
return (totalOrder);
}
int subTotalOrder(int mode,int totalOrder){
switch(mode){
case 0:totalOrder++;
break;
case 1:if(OrderType()==OP_BUY) totalOrder++;
break;
case 2:if(OrderType()==OP_SELL) totalOrder++;
break;
case 3:if(OrderType()>OP_SELL) totalOrder++;
break;
}
return(totalOrder);
}
double TotalProfit(int magicNumber,string pairSymbol) {
double total = 0;
for (int index1 = 0; index1 < OrdersTotal(); index1++) {
OrderSelect(index1, SELECT_BY_POS, MODE_TRADES);
if(pairSymbol==""){
if(magicNumber==0){
total=total + OrderProfit() + OrderSwap();
}else{
if (OrderMagicNumber() == magicNumber){
total=total + OrderProfit() + OrderSwap();
}
}
}else{
if(OrderSymbol()==pairSymbol){
if(magicNumber==0){
total=total + OrderProfit() + OrderSwap();
}else{
if (OrderMagicNumber() == magicNumber){
total=total + OrderProfit() + OrderSwap();
}
}
}
}
}
return (total);
}
void findMagicNumber(int XPOS,int YPOS){
int counter=0;
bool foundMN=false;
for (int index1 = 0; index1 < OrdersTotal(); index1++) {
OrderSelect(index1, SELECT_BY_POS, MODE_TRADES);
//createText(OrderMagicNumber(),9,White,accobj,XPOS+5,YPOS+(index1*15));accobj++;
for(int temp=0;temp<=counter;temp++){
if(OrderMagicNumber()==MN_Array[temp]){
foundMN=true;
break;
}
}
if(foundMN==false){
MN_Array[counter]=OrderMagicNumber();
createText(OrderMagicNumber(),9,White,accobj,XPOS+5,YPOS+(counter*15));accobj++;
counter++;
}else{
foundMN=false;
}
}
createText("more information : victory1@centrin.net.id",9,White,accobj,XPOS,YPOS+(counter*15));accobj++;
}
Comments