mirror of
https://github.com/softwaredevelop/mql5.git
synced 2026-07-28 04:57:44 +00:00
177 lines
14 KiB
Plaintext
177 lines
14 KiB
Plaintext
//+------------------------------------------------------------------+
|
|
//| AccountInfoDisplay.mq5 |
|
|
//| Copyright 2000-2025, MetaQuotes Ltd. |
|
|
//| https://www.mql5.com |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright 2000-2025, MetaQuotes Ltd."
|
|
#property link "https://www.mql5.com"
|
|
//---
|
|
#include <Trade\AccountInfo.mqh>
|
|
#include <ChartObjects\ChartObjectsTxtControls.mqh>
|
|
//---
|
|
#include "AccountInfoDisplayInit.mqh"
|
|
//---
|
|
//+------------------------------------------------------------------+
|
|
//| Account Info Display script class |
|
|
//+------------------------------------------------------------------+
|
|
class CAccountInfoDisplay
|
|
{
|
|
protected:
|
|
CAccountInfo m_account;
|
|
//--- chart objects
|
|
CChartObjectLabel m_label[28];
|
|
CChartObjectLabel m_label_info[28];
|
|
|
|
public:
|
|
CAccountInfoDisplay(void);
|
|
~CAccountInfoDisplay(void);
|
|
//---
|
|
bool Init(void);
|
|
void Deinit(void);
|
|
void Processing(void);
|
|
|
|
private:
|
|
void AccountInfoToChart(void);
|
|
};
|
|
//---
|
|
CAccountInfoDisplay g_accountDisplay;
|
|
//+------------------------------------------------------------------+
|
|
//| Constructor |
|
|
//+------------------------------------------------------------------+
|
|
CAccountInfoDisplay::CAccountInfoDisplay(void)
|
|
{
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Destructor |
|
|
//+------------------------------------------------------------------+
|
|
CAccountInfoDisplay::~CAccountInfoDisplay(void)
|
|
{
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Method Init. |
|
|
//+------------------------------------------------------------------+
|
|
bool CAccountInfoDisplay::Init(void)
|
|
{
|
|
int i;
|
|
int sy=10;
|
|
int dy=16;
|
|
color color_label;
|
|
color color_info;
|
|
color color_heading = clrDarkGray;
|
|
int font_size_data = 8;
|
|
int font_size_heading = 9;
|
|
|
|
//--- tuning colors
|
|
color_info =(color)(ChartGetInteger(0,CHART_COLOR_BACKGROUND)^0xFFFFFF);
|
|
color_label=(color)(color_info^0x202020);
|
|
//---
|
|
if(ChartGetInteger(0,CHART_SHOW_OHLC))
|
|
sy+=16;
|
|
|
|
int current_y = sy;
|
|
|
|
//--- creation Labels[]
|
|
for(i=0;i<ArraySize(init_str);i++)
|
|
{
|
|
bool is_heading = (
|
|
StringFind(init_str[i], "I. ") == 0 ||
|
|
StringFind(init_str[i], "II. ") == 0 ||
|
|
StringFind(init_str[i], "III. ") == 0 ||
|
|
StringFind(init_str[i], "IV. ") == 0 ||
|
|
StringFind(init_str[i], "V. ") == 0
|
|
);
|
|
|
|
m_label[i].Create(0,"Label"+IntegerToString(i),0,20,current_y);
|
|
m_label[i].Description(init_str[i]);
|
|
m_label[i].Color(is_heading ? color_heading : color_label); // Fejléc szín vagy alap szín
|
|
m_label[i].FontSize(is_heading ? font_size_heading : font_size_data); // Fejléc betűméret vagy alap betűméret
|
|
m_label[i].Selectable(false);
|
|
m_label[i].Z_Order(0);
|
|
|
|
m_label_info[i].Create(0,"LabelInfo"+IntegerToString(i),0,120,current_y);
|
|
m_label_info[i].Description(" ");
|
|
m_label_info[i].Color(color_info);
|
|
m_label_info[i].FontSize(font_size_data);
|
|
m_label_info[i].Selectable(false);
|
|
m_label_info[i].Z_Order(0);
|
|
|
|
current_y += dy;
|
|
}
|
|
AccountInfoToChart();
|
|
//--- redraw chart
|
|
ChartRedraw();
|
|
//---
|
|
return(true);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Method Deinit. |
|
|
//+------------------------------------------------------------------+
|
|
void CAccountInfoDisplay::Deinit(void)
|
|
{
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Method Processing. |
|
|
//+------------------------------------------------------------------+
|
|
void CAccountInfoDisplay::Processing(void)
|
|
{
|
|
AccountInfoToChart();
|
|
//--- redraw chart
|
|
ChartRedraw();
|
|
Sleep(50);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Method InfoToChart. |
|
|
//+------------------------------------------------------------------+
|
|
void CAccountInfoDisplay::AccountInfoToChart(void)
|
|
{
|
|
// --- I. Basic Account Information ---
|
|
m_label_info[1].Description((string)m_account.Login());
|
|
m_label_info[2].Description(m_account.Name());
|
|
m_label_info[3].Description(m_account.Server());
|
|
m_label_info[4].Description(m_account.Company());
|
|
m_label_info[5].Description(m_account.Currency());
|
|
m_label_info[6].Description((string)m_account.InfoInteger(ACCOUNT_CURRENCY_DIGITS));
|
|
|
|
// --- II. Financial Status and Balances ---
|
|
m_label_info[8].Description(DoubleToString(m_account.Balance(),2));
|
|
m_label_info[9].Description(DoubleToString(m_account.Credit(),2));
|
|
m_label_info[10].Description(DoubleToString(m_account.Profit(),2));
|
|
m_label_info[11].Description(DoubleToString(m_account.Equity(),2));
|
|
|
|
// --- III. Margin and Risk Management ---
|
|
m_label_info[13].Description(DoubleToString(m_account.Margin(),2));
|
|
m_label_info[14].Description(DoubleToString(m_account.FreeMargin(),2));
|
|
m_label_info[15].Description(DoubleToString(m_account.MarginLevel(),2));
|
|
m_label_info[16].Description(DoubleToString(m_account.MarginCall(),2));
|
|
m_label_info[17].Description(DoubleToString(m_account.MarginStopOut(),2));
|
|
|
|
// --- IV. Trading Modes and Rules ---
|
|
m_label_info[19].Description(m_account.TradeModeDescription());
|
|
m_label_info[20].Description((string)m_account.Leverage());
|
|
m_label_info[21].Description(m_account.MarginModeDescription());
|
|
m_label_info[22].Description(m_account.StopoutModeDescription());
|
|
m_label_info[23].Description((string)m_account.InfoInteger(ACCOUNT_FIFO_CLOSE));
|
|
m_label_info[24].Description((string)m_account.InfoInteger(ACCOUNT_HEDGE_ALLOWED));
|
|
|
|
// --- V. Trading Permissions ---
|
|
m_label_info[26].Description((string)m_account.TradeAllowed());
|
|
m_label_info[27].Description((string)m_account.TradeExpert());
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Script program start function |
|
|
//+------------------------------------------------------------------+
|
|
void OnStart(void)
|
|
{
|
|
//--- call init function
|
|
if(g_accountDisplay.Init())
|
|
{
|
|
//--- cycle until the script is not halted
|
|
while(!IsStopped())
|
|
g_accountDisplay.Processing();
|
|
}
|
|
//--- call deinit function
|
|
g_accountDisplay.Deinit();
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//+------------------------------------------------------------------+
|