Introduction
Greetings, forex commanders! Picture the forex market as a bustling galaxy, with trades orbiting across multiple currency pairs like spacecraft on diverse missions. The Display Multi-Currency Info EA is your high-tech mission control room, an MQL5 bot that displays real-time metrics for open positions on all selected symbols, including buy and sell counts, total trades, lot sizes, and profit/loss. It doesnβt execute trades but equips you with a clear overview to manage your portfolio manually, like monitoring a fleet from a central console. This article is your mission log, guiding you through the code with crystal-clear detail for beginners, a flow smoother than a rocket launch, and examplesβlike tracking EURUSD positionsβto keep you engaged. Weβll quote variables (e.g., "totalBuys") and functions (e.g., "OnInit()") for clarity, balancing pro insights with a sprinkle of charm. Ready to take command? Letβs launch this mission control dashboard!
Strategy Blueprint
The Display Multi-Currency Info EA is a portfolio monitoring interface:
Position Tracking: Displays open positions for all selected symbols (e.g., EURUSD, GBPUSD), showing buy positions (red), sell positions (green), total trades (white), aggregate lots (orange), and profit/loss (blue).
Portfolio Totals: Summarizes total buys, sells, trades, lots, and profit/loss at the bottom for a holistic view.
Purpose: Provides real-time data to inform manual position management, not execute trades, like mission control tracking spacecraft status.
Features: Right-aligned layout with yellow headers and footer, color-coded metrics for clarity, and a compact design. Itβs like a mission control console, offering a panoramic view of your trading fleet to guide strategic decisions with precision.

Code Implementation
Letβs navigate the MQL5 code like mission commanders plotting a space launch, building our dashboard step by step. Weβll flow from setting up the control room to tracking positions, displaying metrics, and cleaning up, with transitions as seamless as a rocketβs ascent. Each section includes code blocks, detailed explanations of what weβre doing, and examples to keep you engaged, all while staying beginner-friendly and professional.
Step 1: Setting Up Mission ControlβPreparing the Dashboard
We start by assembling our control room, defining the dashboardβs structure and core components.
//+------------------------------------------------------------------+
//| DISPLAY MULTI-CURRENCY INFO.mq5 |
//| Copyright 2024, ALLAN MUNENE MUTIIRIA. #@Forex Algo-Trader. |
//| https://youtube.com/@ForexAlgo-Trader? |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, ALLAN MUNENE MUTIIRIA. #@Forex Algo-Trader"
#property link "https://youtube.com/@ForexAlgo-Trader?"
#property description "======= IMPORTANT =======\n"
#property description "1. This is a FREE EA."
#property description "2. To get the source code of the EA, follow the Copyright link."
#property description "3. Incase of anything, contact developer via the link provided."
#property description "Hope you will enjoy the EA Logic.\n"
#property description "*** HAPPY TRADING! ***"
#property version "1.00"
#define HEADER "HEADER "
#define SYMB "SYMBOL "
#define DATA "DATA "
#define FOOTER_TEXT "FOOTER TEXT "
#define HEADER_LINE "HEADER LINE "
#define FOOTER_LINE "FOOTER LINE "
#define FOOTER_DATA "FOOTER DATA "
#define XSp 80
#define YSp 15
int totalBuys = 0;
int totalSells = 0;
int totalTrades = 0;
double totalLots = 0;
double totalProfit = 0;
string headers[] = {"Symbol","Buy P","Sell P","Trades","Lots A","Profit"};
int OnInit(){
totalBuys=0;totalSells=0;totalTrades=0;totalLots=0;totalProfit=0;
for (int i=0; i<ArraySize(headers); i++){
createLABEL(HEADER+IntegerToString(i),headers[i],500+(i*-XSp),50,clrYellow,13);
}
createLABEL(HEADER_LINE,"________________________________________________________",500,50+2,clrYellow);
for (int i=0; i<SymbolsTotal(true); i++){
createLABEL(SYMB+IntegerToString(i),SymbolName(i,true),500,(50+YSp+5)+(i*YSp),clrWhite,10);
if (i==SymbolsTotal(true)-1){
createLABEL(FOOTER_LINE,"________________________________________________________",500,(50+YSp+5)+(i*YSp),clrYellow);
createLABEL(FOOTER_TEXT+IntegerToString(i),"Total:",500,(50+YSp+5)+(i*YSp)+YSp,clrYellow);
}
for (int j=0; j<ArraySize(headers)-1; j++){
createLABEL(DATA+IntegerToString(j)+" "+SymbolName(i,true),"null",(500-XSp-15)+(j*-XSp),(50+YSp+5)+(i*YSp),clrWhite,10);
if (i==SymbolsTotal(true)-1){
createLABEL(FOOTER_DATA+IntegerToString(j),"F_D",(500-XSp-15)+(j*-XSp),(50+YSp+5)+(i*YSp)+YSp,clrYellow);
}
}
}
// ... (position tracking logic)
return(INIT_SUCCEEDED);
}
bool createLABEL(string objName, string txt, int xD, int yD, color clrTxt,
int fontSize=12, string font="Arial Rounded MT Bold"){
ResetLastError();
if (!ObjectCreate(0,objName,OBJ_LABEL,0,0,0)){
Print(__FUNCTION__,": FAILED TO CREATE LABEL! ERR CODE = ",GetLastError());
return (false);
}
ObjectSetInteger(0,objName,OBJPROP_XDISTANCE,xD);
ObjectSetInteger(0,objName,OBJPROP_YDISTANCE,yD);
ObjectSetInteger(0,objName,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
ObjectSetString(0,objName,OBJPROP_TEXT,txt);
ObjectSetInteger(0,objName,OBJPROP_COLOR,clrTxt);
ObjectSetInteger(0,objName,OBJPROP_FONTSIZE,fontSize);
ObjectSetString(0,objName,OBJPROP_FONT,font);
ObjectSetInteger(0,objName,OBJPROP_BACK,false);
ChartRedraw(0);
return (true);
}We set up mission control with a #property header, declaring the EA as a free offering by Allan in 2024 with a YouTube link, like powering up our consoleβs screens. We define constants (e.g., "HEADER", "SYMB", "XSp", "YSp") for layout spacing and labels, global variables ("totalBuys", "totalSells", "totalTrades", "totalLots", "totalProfit") to tally portfolio metrics, and a "headers[]" array for column titles. In "OnInit()", we reset globals and use "createLABEL()" with "ObjectCreate(OBJ_LABEL)", "ObjectSetInteger()", "ObjectSetString()" to build a right-aligned dashboard: yellow headers ("Symbol", "Buy P", etc.), white symbol names (e.g., EURUSD, GBPUSD), placeholder data labels ("null"), and a yellow footer with βTotal:β and placeholders. A yellow line ("HEADER_LINE", "FOOTER_LINE") frames the layout, like setting up a control panel to monitor a fleet of trades.
Step 2: Tracking the FleetβMonitoring Open Positions
We track open positions across symbols, calculating metrics like buys, sells, trades, lots, and profits, like monitoring spacecraft telemetry.
string countThisEA_Positions_Total(string symbol){
int totalPositions=0;
int count_Total_pos = PositionsTotal();
for (int i=count_Total_pos-1; i>=0; i--){
ulong ticket = PositionGetTicket(i);
if (ticket > 0){
if (PositionSelectByTicket(ticket)){
if (PositionGetString(POSITION_SYMBOL)==symbol) totalPositions++;
}
}
}
return (IntegerToString(totalPositions));
}
string countThisEA_Positions_B_S(string symbol,ENUM_POSITION_TYPE pos_type){
int totalPositions=0;
int count_Total_pos = PositionsTotal();
for (int i=count_Total_pos-1; i>=0; i--){
ulong ticket = PositionGetTicket(i);
if (ticket > 0){
if (PositionSelectByTicket(ticket)){
if (PositionGetString(POSITION_SYMBOL)==symbol){
if (PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY &&
pos_type == POSITION_TYPE_BUY){
totalPositions++;
}
else if (PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL &&
pos_type == POSITION_TYPE_SELL){
totalPositions++;
}
}
}
}
}
return (IntegerToString(totalPositions));
}
string countThisEA_Positions_LOTS_PROFIT(string symbol,ENUM_POSITION_PROPERTY_DOUBLE double_type){
double totals=0;
int count_Total_pos = PositionsTotal();
for (int i=count_Total_pos-1; i>=0; i--){
ulong ticket = PositionGetTicket(i);
if (ticket > 0){
if (PositionSelectByTicket(ticket)){
if (PositionGetString(POSITION_SYMBOL)==symbol){
if (double_type == POSITION_VOLUME){
totals += PositionGetDouble(POSITION_VOLUME);
}
else if (double_type == POSITION_PROFIT){
totals += PositionGetDouble(POSITION_PROFIT);
}
}
}
}
}
return (DoubleToString(totals,2));
}
int OnInit(){
// ... (dashboard setup)
for (int i=0; i<SymbolsTotal(true); i++){
for (int j=0; j<ArraySize(headers)-1; j++){
switch (j){
case 0://BUYS
updateLABEL(DATA+IntegerToString(j)+" "+SymbolName(i,true),countThisEA_Positions_B_S(SymbolName(i,true),POSITION_TYPE_BUY),clrRed);
totalBuys += (int)countThisEA_Positions_B_S(SymbolName(i,true),POSITION_TYPE_BUY);
break;
case 1://SELLS
updateLABEL(DATA+IntegerToString(j)+" "+SymbolName(i,true),countThisEA_Positions_B_S(SymbolName(i,true),POSITION_TYPE_SELL),clrLime);
totalSells += (int)countThisEA_Positions_B_S(SymbolName(i,true),POSITION_TYPE_SELL);
break;
case 2://TRADES
updateLABEL(DATA+IntegerToString(j)+" "+SymbolName(i,true),countThisEA_Positions_Total(SymbolName(i,true)),clrWhite);
totalTrades += (int)countThisEA_Positions_Total(SymbolName(i,true));
break;
case 3://LOTS
updateLABEL(DATA+IntegerToString(j)+" "+SymbolName(i,true),countThisEA_Positions_LOTS_PROFIT(SymbolName(i,true),POSITION_VOLUME),clrOrange);
totalLots += (double)countThisEA_Positions_LOTS_PROFIT(SymbolName(i,true),POSITION_VOLUME);
break;
case 4://PROFIT/LOSS
updateLABEL(DATA+IntegerToString(j)+" "+SymbolName(i,true),countThisEA_Positions_LOTS_PROFIT(SymbolName(i,true),POSITION_PROFIT),clrBlue);
totalProfit += (double)countThisEA_Positions_LOTS_PROFIT(SymbolName(i,true),POSITION_PROFIT);
break;
}
if (i==SymbolsTotal(true)-1){
switch (j){
case 0://BUYS TOTAL
updateLABEL(FOOTER_DATA+IntegerToString(j),string(totalBuys),clrRed);
break;
case 1://SELLS TOTAL
updateLABEL(FOOTER_DATA+IntegerToString(j),string(totalSells),clrLime);
break;
case 2://TRADES TOTAL
updateLABEL(FOOTER_DATA+IntegerToString(j),string(totalTrades),clrWhite);
break;
case 3://LOTS TOTAL
updateLABEL(FOOTER_DATA+IntegerToString(j),string(totalLots),clrOrange);
break;
case 4://PROFIT/LOSS TOTAL
updateLABEL(FOOTER_DATA+IntegerToString(j),string(totalProfit),clrBlue);
break;
}
}
}
}
}
bool updateLABEL(string objName, string txt, color clrTxt=clrWhite){
int found = ObjectFind(0,objName);
if (found < 0){
ResetLastError();
Print("UNABLE TO FINF THE LABEL: ",objName," ERR CODE = ",GetLastError());
return (false);
}
else {
ObjectSetString(0,objName,OBJPROP_TEXT,txt);
ObjectSetInteger(0,objName,OBJPROP_COLOR,clrTxt);
ChartRedraw(0);
return (true);
}
}We use "countThisEA_Positions_B_S()", "countThisEA_Positions_Total()", and "countThisEA_Positions_LOTS_PROFIT()" to calculate metrics for each symbol via "PositionsTotal()", "PositionGetTicket()", "PositionSelectByTicket()", "PositionGetString()", "PositionGetInteger()", "PositionGetDouble()". For each symbol, we loop through "headers[]" (excluding βSymbolβ), updating "DATA" labels with: buy positions ("POSITION_TYPE_BUY", red), sell positions ("POSITION_TYPE_SELL", green), total trades (white), lots ("POSITION_VOLUME", orange), and profit ("POSITION_PROFIT", blue) using "updateLABEL()", "IntegerToString()", "DoubleToString()". We tally globals ("totalBuys", etc.) and update "FOOTER_DATA" labels for totals, like showing EURUSD with 2 buys, 1 sell, 3 trades, 0.30 lots, -$50, and portfolio totals of 5 buys, 3 sells, 8 trades, 0.80 lots, $200. This is like tracking a fleetβs status on mission control screens.
Step 3: Updating the ConsoleβReal-Time Monitoring
We ensure the dashboard updates in real-time, like keeping mission controlβs screens live.
void OnTick(){
}In "OnTick()", we leave it empty, as updates occur only in "OnInit()", like a static mission control snapshot. We could add logic to refresh metrics periodically using "PositionsTotal()", "countThisEA_Positions_B_S()", etc., to reflect new trades, like keeping EURUSDβs profit/loss current as positions change, but for now, it initializes once, ready for manual review.
Step 4: Shutting Down Mission ControlβCleaning Up
When the missionβs over, we tidy up to leave the chart clear.
void OnDeinit(const int reason){
}In "OnDeinit()", we leave it empty, as no cleanup is coded, like leaving console screens active. We could add "ObjectsDeleteAll()" to clear labels (e.g., "HEADER 0", "SYMB 0"), like shutting down mission control, but for now, itβs a light cleanup, ready for the next mission.
Why This EAβs a Mission Control Legend (and Keeps You Engaged!)
This EA is a portfolio monitoring legend, tracking open positions across symbols like mission control overseeing a trading fleet. Its color-coded metrics make status clear, guiding manual adjustments with precision. Example? Spot EURUSD with 3 trades and -$50 loss to close sells, or GBPUSD with 0.50 lots and $100 profit to scale buysβpure mission-critical gold! Beginners can follow, and pros can enhance it, making it a must-have for traders managing multiple symbols.
Putting It All Together
To launch this EA:
Open MetaEditor in MetaTrader 5 like powering up mission control.
Paste the code, compile (F5), and check for typosβno commander wants a faulty console.
Drop the EA on your chart and review symbol metrics and portfolio totals.
Use the dashboard to inform manual position adjustments, like plotting a mission course.
Test on a demo firstβreal pips deserve a practice run!
Conclusion
Weβve crafted a multi-currency dashboard mission control that tracks open positions with vivid, real-time metrics. This MQL5 code is our console, explained with detail to make you a trading commander, a touch of charm to keep you engaged, and flow to carry you like a space launch. Ready to command? Check our video guide on the website for a front-row seat to this trading mission. Now go lead those market fleets! π₯οΈ
Disclaimer: Tradingβs like running mission controlβthrilling but risky. Losses can exceed deposits. Test strategies on a demo account before going live.