EA-Setka-2/Libs/CtrlPanel/CtrlPanelComment.mqh

182 lines
13 KiB
MQL5
Raw Permalink Normal View History

2025-05-30 14:50:44 +02:00
<EFBFBD><EFBFBD>//+------------------------------------------------------------------+
//| CtrlPanelComment.mqh |
//| Copyright 2021, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#ifndef CTRL_PANEL_COMMENT_MQH
#define CTRL_PANEL_COMMENT_MQH
/*
0@0<5B@K 4>ABC?=K5 4;O =0AB@>9:8 ?0=5;8
bool auto_colors - 02B> F25B0
bool graph_comment - ?0=5;L 2 2845 B5:AB>2KE :><5=B0@852 8;8 2 2845 ?0=5;8
-- @07<5@K H@8DB0
string font
int font_size
bool font_bold
double font_interval
-- &25B0
color color_back
color color_border
color color_caption
color color_text
color color_buy
color color_sell
color color_err
int opacity
*/
// =0G5=8O ?> C<>;G0=8N
//--- custom colors
#define CTRL_PANEL_COLOR_BACK clrBlack
#define CTRL_PANEL_COLOR_BORDER clrDimGray
#define CTRL_PANEL_COLOR_CAPTION clrDodgerBlue
#define CTRL_PANEL_COLOR_TEXT clrLightGray
#define CTRL_PANEL_COLOR_BUY clrLimeGreen
#define CTRL_PANEL_COLOR_SELL clrOrangeRed
#define CTRL_PANEL_COLOR_ERR clrRed
//--- input parameters
#define CTRL_PANEL_AUTO_COLORS false //Auto Colors
#define CTRL_PANEL_OPACITY 200 // @>7@0G=>ABL :><<5=B0@852 (0-255)
#define CTRL_PANEL_GRAPH_COMMENT true // @0D8G5A:85/B5:AB>2K5 :><<5=B0@88
// 0@0<5B@K H@8DB0 ?> C<>;G0=8N
#define CTRL_PANEL_FONT "Lucida Console"
#define CTRL_PANEL_FONT_SIZE 12
#define CTRL_PANEL_FONT_BOLD false
#define CTRL_PANEL_FONT_INTERVAL 1.2
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CCtrlPanelComment: public CCtrlPanelLevels
{
public:
CCtrlPanelComment() {};
CCtrlPanelComment(const string param);
//--- =8F80;870F8O/458=8F80;870F8O
virtual bool OnInitEvent(void);
virtual void OnDeinitEvent(const int reason);
//--- 1@01>BG8: B8:>2
virtual void DrawPanelInfo();
//--- 1@01>BG8: A>1KB8O 3@0D8:0
virtual void OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);
virtual void CreatePanelItems()=0;
protected:
bool CreatePanel();
protected:
CComment _panel;
color _color_caption;
color _color_text;
color _color_buy;
color _color_sell;
color _color_err;
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
CCtrlPanelComment::CCtrlPanelComment(const string param):CCtrlPanelLevels(param)
{
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool CCtrlPanelComment::OnInitEvent(void)
{
if(!CCtrlPanelLevels::OnInitEvent())
return false;
if(!CreatePanel())
return false;
_color_caption=GetParamColor("color_caption",CTRL_PANEL_COLOR_CAPTION);
_color_text=GetParamColor("color_text",CTRL_PANEL_COLOR_TEXT);
_color_buy=GetParamColor("color_buy",CTRL_PANEL_COLOR_BUY);
_color_sell=GetParamColor("color_sell",CTRL_PANEL_COLOR_SELL);
_color_err=GetParamColor("color_err",CTRL_PANEL_COLOR_ERR);
CreatePanelItems();
if(kernel_account::is_testing() && kernel_account::is_visual_mode())
_panel.SetText(_panel.GetList().Total(),CTRL_PANEL_WARNING_SLOW_TESTING,_color_err);
return true;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CCtrlPanelComment::OnDeinitEvent(const int reason)
{
CCtrlPanelLevels::OnDeinitEvent(reason);
_panel.Destroy();
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CCtrlPanelComment::OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
{
_panel.OnChartEvent(id,lparam,dparam,sparam);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool CCtrlPanelComment::CreatePanel(void)
{
//--- panel position
int y=30;
if(ChartGetInteger(0,CHART_SHOW_ONE_CLICK))
y=120;
//--- panel name
string name="ctrl_panel_"+VER;
_panel.Create(name,20,y);
//--- panel style
_panel.SetAutoColors(GetParamBool("auto_colors",CTRL_PANEL_AUTO_COLORS));
_panel.SetColor(GetParamColor("color_border",CTRL_PANEL_COLOR_BORDER), GetParamColor("color_back",CTRL_PANEL_COLOR_BACK),(uchar)GetParamInt("opacity", CTRL_PANEL_OPACITY));
_panel.SetFont(GetParamString("font",CTRL_PANEL_FONT),GetParamInt("font_size",CTRL_PANEL_FONT_SIZE),GetParamBool("font_bold",CTRL_PANEL_FONT_BOLD),GetParamDouble("font_interval",CTRL_PANEL_FONT_INTERVAL));
_panel.SetGraphMode(GetParamBool("graph_comment",CTRL_PANEL_GRAPH_COMMENT));
return true;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CCtrlPanelComment::DrawPanelInfo()
{
DrawGridLevel(_sell_grid_levels,_sell_lvl_no_loss,_sell_lvl_stop, _sell_lvl_first_order, _sell_lvl_no_first_order);
DrawGridLevel(_buy_grid_levels,_buy_lvl_no_loss,_buy_lvl_stop, _buy_lvl_first_order, _buy_lvl_no_first_order);
_panel.Show();
_readyForUpdate=false;
}
#endif
//+------------------------------------------------------------------+