__indicate_orders
Download scriptThis script is designed to provide a real-time, visual summary of your open trading positions directly on your MetaTrader platform. It acts as an automated dashboard that tracks your active trades, categorizes them by type (Buy vs. Sell), and calculates their individual and collective financial status.
Core Functionality
Real-Time Data Tracking The script automatically scans all your currently active trades. It filters this information to ensure it only displays data relevant to the specific currency pair or asset you are currently viewing. This prevents clutter by ignoring unrelated trades from other markets.
Automated Summaries For both "Buy" and "Sell" categories, the script generates a high-level summary line. This header provides:
- The total count of open positions for that category.
- The cumulative trading volume (lot size).
- The total net profit or loss for those positions.
Detailed Individual Breakdown Beneath the main summaries, the script lists every individual trade specifically. For each transaction, it displays:
- The unique identification number (Ticket) of the trade.
- The specific volume/lot size of that trade.
- The current floating profit or loss for that specific position.
Visual Indicators To help you make quick decisions, the script uses color-coding to highlight your financial status:
- Profitable Positions: Displayed in a distinct "DeepSkyBlue" color, allowing you to easily identify winning trades at a glance.
- Losing Positions: Displayed in "DeepPink," providing an immediate visual warning for trades currently in the red.
User Experience & Customization
The script is built to be clean and organized. It includes several customizable settings that allow you to adjust how the information appears on your screen:
- Font Styling: You can choose the font name and specific sizes for both the main headers and the individual trade list.
- Positioning: You can define which corner of the chart the information should appear in and set exact distances from the edges so it doesn't obstruct your price candles.
- Spacing: The layout can be adjusted to ensure there is enough vertical space between each line of data for clear readability.
- Capacity: It is pre-configured to handle a large number of simultaneous positions (up to 25) without overlapping or disappearing.
In essence, this tool transforms raw trading data into an organized, color-coded dashboard, giving you a clear and instant overview of your portfolio's health without having to manually calculate totals.
//+------------------------------------------------------------------+
//| #_indicate_orders.mq4 |
//| Àëåêñàíäð Ñìèðíîâ |
//| rainal@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Àëåêñàíäð Ñìèðíîâ"
#property link "rainal@mail.ru"
extern string font_name = "Tahoma"; // øðèôò òåêñòîâûõ ìåòîê
extern int font_size1 = 10; // ðàçìåð øðèôòà çàãîëîâêîâ
extern int font_size2 = 9; // ðàçìåð øðèôòà ñïèñêà ïîçèöèé
extern int labs_corner = 1; // óãîë ïðèâÿçêè òåêñòîâûõ ìåòîê
extern int labs_xdist = 5; // ðàñcòîÿíèå X îò ãðàíèöû îêíà
extern int labs_ydist = 10; // ðàññòîÿíèå Y îò ãðàíèöû îêíà
extern int labs_space = 17; // èíòåðâàë Y ìåæäó ìåòêàìè
extern int labs_max = 25; // ìàêñèìàëüíîå êîëè÷åñòâî ìåòîê
extern color clr_profit = DeepSkyBlue; // öâåò ïðîôèòíûõ ïîçèöèé
extern color clr_loss = DeepPink; // öâåò óáûòî÷íûõ ïîçèöèé
//--------------------------------------------------------------------------+
void init()
{
// ñîçäàíèå 25 òåêñòîâûõ ïîëÿ äëÿ âûâîäà èíôîðìàöèè
for(int i = 1; i <= labs_max; i++)
{
ObjectCreate("lab"+i, OBJ_LABEL, 0, 0, 0);
ObjectSet("lab"+i, OBJPROP_CORNER, labs_corner);
ObjectSet("lab"+i, OBJPROP_XDISTANCE, labs_xdist);
ObjectSet("lab"+i, OBJPROP_YDISTANCE, i * labs_space + labs_ydist);
ObjectSetText("lab"+i, "");
}
}
//--------------------------------------------------------------------------+
void deinit()
{
// óäàëåíèå âñåõ òåêñòîâûõ ïîëåé
for(int i = 1; i <= labs_max; i++) ObjectDelete("lab"+i);
}
//--------------------------------------------------------------------------+
void indicate_orders()
{
int i, nb = 0, ns = 0, lab = 1, lbn = 0;
int buys_profit = 0, sells_profit = 0;
double buys_volume = 0.0, sells_volume = 0.0;
double buys_list[50][3];
double sells_list[50][3];
string res;
// ïîäñ÷åò âñåõ îòêðûòûõ ïîçèöèé íà äàííûé ìîìåíò ïî òåêóùåé ïàðå
for(i = 0; i < OrdersTotal(); i++)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) break;
if(OrderSymbol() != Symbol()) continue;
if(OrderType() == OP_BUY)
{
buys_list[nb][0] = OrderTicket();
buys_list[nb][1] = OrderProfit();
buys_list[nb][2] = OrderLots();
buys_profit += buys_list[nb][1];
buys_volume += buys_list[nb][2];
nb++;
}
if(OrderType() == OP_SELL)
{
sells_list[ns][0] = OrderTicket();
sells_list[ns][1] = OrderProfit();
sells_list[ns][2] = OrderLots();
sells_profit += sells_list[ns][1];
sells_volume += sells_list[ns][2];
ns++;
}
}
// îòîáðàæåíèå âñåõ îòêðûòûõ ïîçèöèé
if(nb > 0)
{
ArrayResize(buys_list, nb);
if(buys_profit > 0)
{
res = "BUYS | " + nb + " | " + DoubleToStr(buys_volume, 2) + " | + " + buys_profit;
ObjectSetText("lab"+lab, res, font_size1, font_name, clr_profit);
lab++;
ObjectSetText("lab"+lab, "------------------", font_size1, font_name, clr_profit);
}
else
{
res = "BUYS | " + nb + " | " + DoubleToStr(buys_volume, 2) + " | " + buys_profit;
ObjectSetText("lab"+lab, res, font_size1, font_name, clr_loss);
lab++;
ObjectSetText("lab"+lab, "------------------", font_size1, font_name, clr_loss);
}
lab++;
lbn = lab;
for(i = 0; i < nb; i++)
{
lab = lbn + i;
if(buys_list[i][1] > 0)
{
res = "#" + DoubleToStr(buys_list[i][0], 0) + ": " + DoubleToStr(buys_list[i][2], 2) + ": +" + DoubleToStr(buys_list[i][1], 0);
ObjectSetText("lab"+lab, res, font_size2, font_name, clr_profit);
}
else
{
res = "#" + DoubleToStr(buys_list[i][0], 0) + ": " + DoubleToStr(buys_list[i][2], 2) + ": " + DoubleToStr(buys_list[i][1], 0);
ObjectSetText("lab"+lab, res, font_size2, font_name, clr_loss);
}
}
}
if(ns > 0)
{
ArrayResize(sells_list, ns);
if(nb > 0)
{
lab++;
ObjectSetText("lab"+lab, "");
lab++;
}
if(sells_profit > 0)
{
res = "SELLS | " + ns + " | " + DoubleToStr(sells_volume, 2) + " | +" + sells_profit;
ObjectSetText("lab"+lab, res, font_size1, font_name, clr_profit);
lab++;
ObjectSetText("lab"+lab, "------------------", font_size1, font_name, clr_profit);
}
else
{
res = "SELLS | " + ns + " | " + DoubleToStr(sells_volume, 2) + " | " + sells_profit;
ObjectSetText("lab"+lab, res, font_size1, font_name, clr_loss);
lab++;
ObjectSetText("lab"+lab, "------------------", font_size1, font_name, clr_loss);
}
lab++;
lbn = lab;
for(i = 0; i < ns; i++)
{
lab = lbn + i;
if(sells_list[i][1] > 0)
{
res = "#" + DoubleToStr(sells_list[i][0], 0) + ": " + DoubleToStr(sells_list[i][2], 2) + ": +" + DoubleToStr(sells_list[i][1], 0);
ObjectSetText("lab"+lab, res, font_size2, font_name, clr_profit);
}
else
{
res = "#" + DoubleToStr(sells_list[i][0], 0) + ": " + DoubleToStr(sells_list[i][2], 2) + ": " + DoubleToStr(sells_list[i][1], 0);
ObjectSetText("lab"+lab, res, font_size2, font_name, clr_loss);
}
}
}
for(i = lab+1; i <= labs_max; i++) ObjectSetText("lab"+i, "");
}
//--------------------------------------------------------------------------+
void start()
{
indicate_orders();
//
// âàø òåêñò ñîâåòíèêà
//
}
Comments