Discussion of article "DoEasy. Controls (Part 31): Scrolling the contents of the ScrollBar control"
For such works, a monument will be erected probably on mql5, descendants))) What is worth one file defines.mqh, in 4k lines. If you look at the difference between 70 parts and 131 parts, it 's amazing how much work there is )))
I found a small error, in the file trading.mqh, SetPrices, has the visibility private, not protected, the descendants can not use the function. From the file TradingControl.mqh, CreatePReqClose(), there are errors of use.
private: template <typename PR,typename SL,typename TP,typename PL> bool SetPrices(const ENUM_ORDER_TYPE action,const PR price,const SL sl,const TP tp,const PL limit,const string source_method,CSymbol *symbol_obj);
For such works, a monument will be erected probably on mql5, descendants))) What is worth one file defines.mqh, in 4k lines. If you look at the difference between 70 parts and 131 parts, it 's amazing how much work there is )))
I found a small error, in the file trading.mqh, SetPrices, has the visibility private, not protected, the descendants can not use the function. From the file TradingControl.mqh, CreatePReqClose(), there are errors of use.
Yes. This error was my oversight and the error of the old compiler that missed it. In the latest versions of the compiler the error was detected and I fixed it. In recent versions of the library, the methods are in the protected section, not the private section
Wouldn't it be better to create a structure and turn strings into a CharArray array?
ulong m_ticket; // Ticket of the selected order/trade (MQL5) long m_long_prop[ORDER_PROP_INTEGER_TOTAL]; // Integer properties double m_double_prop[ORDER_PROP_DOUBLE_TOTAL]; // Substantial properties string m_string_prop[ORDER_PROP_STRING_TOTAL]; // String properties
//--- Creates a new chart object, returns a pointer to the chart control object CChartObjectsControl *CreateNewStdGraphObjectAndGetCtrlObj(const long chart_id, const string name, int subwindow, const ENUM_OBJECT type_object, const datetime time1, const double price1, const datetime time2=0, const double price2=0, const datetime time3=0, const double price3=0, const datetime time4=0, const double price4=0, const datetime time5=0, const double price5=0) { //--- If the object with chart ID and name already exists in the collection - report it and return NULL if(this.IsPresentGraphObjInList(chart_id,name)) { ::Print(DFUN,CMessage::Text(MSG_GRAPH_ELM_COLLECTION_ERR_GR_OBJ_ALREADY_EXISTS)," ChartID ",(string)chart_id,", ",name); return NULL; } //--- If a new standard graphical object could not be created - report it and return NULL if(!CreateNewStdGraphObject(chart_id,name,type_object,subwindow,time1,price1,time2,price2,time3,price3,time4,price4,time5,price5)) { ::Print(DFUN,CMessage::Text(MSG_GRAPH_STD_OBJ_ERR_FAILED_CREATE_STD_GRAPH_OBJ),StdGraphObjectTypeDescription(type_object)); CMessage::ToLog(::GetLastError(),true); return NULL; } //--- If the schedule control object could not be obtained - report it CChartObjectsControl *ctrl=this.GetChartObjectCtrlObj(chart_id); if(ctrl==NULL) ::Print(DFUN,CMessage::Text(MSG_GRAPH_ELM_COLLECTION_ERR_FAILED_GET_CTRL_OBJ),(string)chart_id); //--- Return a pointer to the schedule control object, or NULL in case of an error of receiving it return ctrl; }
I tried to create a simple object (text label), but I couldn't.
After CreateNewStdGraphObject(), how should the created object get into m_list_charts_control to get a non-zero object in the next call?
CChartObjectsControl *ctrl=this.GetChartObjectCtrlObj(chart_id);
//--- Creates a graphical object "Text Label" bool CreateTextLabel(const long chart_id,const string name,const int subwindow,const bool extended, const int x,const int y, const string text,const int size,const ENUM_BASE_CORNER corner, const ENUM_ANCHOR_POINT anchor_point,const double angle) { string nm=this.m_name_program+"_"+name; ENUM_OBJECT type_object=OBJ_LABEL; CChartObjectsControl *ctrl=this.CreateNewStdGraphObjectAndGetCtrlObj(chart_id,nm,subwindow,type_object,0,0); if(ctrl==NULL) return false;
Returns false before reaching the property setting.
//+------------------------------------------------------------------+ //| Returns the bar object by time in the time series | //+------------------------------------------------------------------+ CBar *CSeriesDE::GetBar(const datetime time) { CBar *obj=new CBar(); if(obj==NULL) return NULL; obj.SetSymbolPeriod(this.m_symbol,this.m_timeframe,time); this.m_list_series.Sort(SORT_BY_BAR_TIME); int index=this.m_list_series.Search(obj); delete obj; return this.m_list_series.At(index); }
Here timeseries is not sorting for me.... The Sort() method in CArray should be implemented separately in an inherited class to sort objects, no?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article DoEasy. Controls (Part 31): Scrolling the contents of the ScrollBar control has been published:
In this article, I will implement the functionality of scrolling the contents of the container using the buttons of the horizontal scrollbar.
Compile the EA and launch it on the chart:
As you can see, the scrolling managed by the arrow buttons works well. When trying to move the slider with the mouse, it "resists", which is natural - we still do not have processing of the slider shift, but we already have a recalculation of its size and coordinates. So, when we try to move the slider with the mouse, the method of setting its coordinates returns it to the position that corresponds to the position of the container content in its visible area. This behavior will be finalized in the subsequent articles.
Author: Artyom Trishkin