diff --git a/ChartObjects/ChartObject.mqh b/ChartObjects/ChartObject.mqh new file mode 100644 index 0000000..062821a --- /dev/null +++ b/ChartObjects/ChartObject.mqh @@ -0,0 +1,1000 @@ +//+------------------------------------------------------------------+ +//| ChartObject.mqh | +//| Copyright 2000-2024, MetaQuotes Ltd. | +//| https://www.mql5.com | +//+------------------------------------------------------------------+ +#include +//+------------------------------------------------------------------+ +//| Class CChartObject. | +//| Pupose: Base class of chart objects. | +//| Derives from class CObject. | +//+------------------------------------------------------------------+ +class CChartObject : public CObject + { +protected: + long m_chart_id; // identifier of chart the object belongs to + int m_window; // number of subwindow (0 - main window) + string m_name; // unique name object name + int m_num_points; // number of anchor points of object + +public: + CChartObject(void); + ~CChartObject(void); + //--- method of identifying the object + virtual int Type(void) const { return(0x8888); } + //--- methods of access to protected data + long ChartId(void) const { return(m_chart_id); } + int Window(void) const { return(m_window); } + string Name(void) const { return(m_name); } + bool Name(const string name); + int NumPoints(void) const { return(m_num_points); } + //--- methods of filling the object + bool Attach(long chart_id,const string name,const int window,const int points); + bool SetPoint(const int point,const datetime time,const double price) const; + //--- methods of deleting + bool Delete(void); + void Detach(void); + //--- methods of access to properties of the object + datetime Time(const int point) const; + bool Time(const int point,const datetime time) const; + double Price(const int point) const; + bool Price(const int point,const double price) const; + color Color(void) const; + bool Color(const color new_color) const; + ENUM_LINE_STYLE Style(void) const; + bool Style(const ENUM_LINE_STYLE new_style) const; + int Width(void) const; + bool Width(const int new_width) const; + bool Background(void) const; + bool Background(const bool new_back) const; + bool Fill(void) const; + bool Fill(const bool new_fill) const; + long Z_Order(void) const; + bool Z_Order(const long value) const; + bool Selected(void) const; + bool Selected(const bool new_sel) const; + bool Selectable(void) const; + bool Selectable(const bool new_sel) const; + string Description(void) const; + bool Description(const string new_text) const; + string Tooltip(void) const; + bool Tooltip(const string new_text) const; + int Timeframes(void) const; + virtual bool Timeframes(const int timeframes) const; + datetime CreateTime(void) const; + int LevelsCount(void) const; + bool LevelsCount(const int new_count) const; + //--- methods to access the properties of levels of objects + color LevelColor(const int level) const; + bool LevelColor(const int level,const color new_color) const; + ENUM_LINE_STYLE LevelStyle(const int level) const; + bool LevelStyle(const int level,const ENUM_LINE_STYLE new_style) const; + int LevelWidth(const int level) const; + bool LevelWidth(const int level,const int new_width) const; + double LevelValue(const int level) const; + bool LevelValue(const int level,const double new_value) const; + string LevelDescription(const int level) const; + bool LevelDescription(const int level,const string new_text) const; + //--- access methods to the API functions of MQL5 + long GetInteger(const ENUM_OBJECT_PROPERTY_INTEGER prop_id,const int modifier=-1) const; + bool GetInteger(const ENUM_OBJECT_PROPERTY_INTEGER prop_id,const int modifier,long &value) const; + bool SetInteger(const ENUM_OBJECT_PROPERTY_INTEGER prop_id,const int modifier,const long value) const; + bool SetInteger(const ENUM_OBJECT_PROPERTY_INTEGER prop_id,const long value) const; + double GetDouble(const ENUM_OBJECT_PROPERTY_DOUBLE prop_id,const int modifier=-1) const; + bool GetDouble(const ENUM_OBJECT_PROPERTY_DOUBLE prop_id,const int modifier,double &value) const; + bool SetDouble(const ENUM_OBJECT_PROPERTY_DOUBLE prop_id,const int modifier,const double value) const; + bool SetDouble(const ENUM_OBJECT_PROPERTY_DOUBLE prop_id,const double value) const; + string GetString(const ENUM_OBJECT_PROPERTY_STRING prop_id,const int modifier=-1) const; + bool GetString(const ENUM_OBJECT_PROPERTY_STRING prop_id,const int modifier,string &value) const; + bool SetString(const ENUM_OBJECT_PROPERTY_STRING prop_id,const int modifier,const string value) const; + bool SetString(const ENUM_OBJECT_PROPERTY_STRING prop_id,const string value) const; + //--- methods of moving + bool ShiftObject(const datetime d_time,const double d_price) const; + bool ShiftPoint(const int point,const datetime d_time,const double d_price) const; + //--- methods for working with files + virtual bool Save(const int file_handle); + virtual bool Load(const int file_handle); + }; +//+------------------------------------------------------------------+ +//| Constructor | +//+------------------------------------------------------------------+ +CChartObject::CChartObject(void) + { +//--- initialize protected data + Detach(); + } +//+------------------------------------------------------------------+ +//| Destructor | +//+------------------------------------------------------------------+ +CChartObject::~CChartObject(void) + { + if(m_chart_id!=-1) + ObjectDelete(m_chart_id,m_name); + } +//+------------------------------------------------------------------+ +//| Changing name of the object | +//+------------------------------------------------------------------+ +bool CChartObject::Name(const string name) + { +//--- check + if(m_chart_id==-1) + return(false); +//--- change + if(ObjectSetString(m_chart_id,m_name,OBJPROP_NAME,name)) + { + m_name=name; + return(true); + } +//--- failure + return(false); + }; +//+------------------------------------------------------------------+ +//| Attach object | +//+------------------------------------------------------------------+ +bool CChartObject::Attach(long chart_id,const string name,const int window,const int points) + { +//--- check + if(ObjectFind(chart_id,name)<0) + return(false); +//--- attach + if(chart_id==0) + chart_id=ChartID(); + m_chart_id =chart_id; + m_window =window; + m_name =name; + m_num_points=points; +//--- successful + return(true); + } +//+------------------------------------------------------------------+ +//| Setting new coordinates of anchor point of an object | +//+------------------------------------------------------------------+ +bool CChartObject::SetPoint(const int point,const datetime time,const double price) const + { +//--- check + if(m_chart_id==-1) + return(false); + if(point>=m_num_points) + return(false); +//--- result + return(ObjectMove(m_chart_id,m_name,point,time,price)); + } +//+------------------------------------------------------------------+ +//| Delete an object | +//+------------------------------------------------------------------+ +bool CChartObject::Delete(void) + { +//--- checki + if(m_chart_id==-1) + return(false); +//--- actions + bool result=ObjectDelete(m_chart_id,m_name); + Detach(); +//--- result + return(result); + } +//+------------------------------------------------------------------+ +//| Detach object | +//+------------------------------------------------------------------+ +void CChartObject::Detach(void) + { + m_chart_id =-1; + m_window =-1; + m_name =NULL; + m_num_points=0; + } +//+------------------------------------------------------------------+ +//| Get the time coordinate of the specified anchor point of object | +//+------------------------------------------------------------------+ +datetime CChartObject::Time(const int point) const + { +//--- check + if(m_chart_id==-1) + return(0); + if(point>=m_num_points) + return(0); +//--- result + return((datetime)ObjectGetInteger(m_chart_id,m_name,OBJPROP_TIME,point)); + } +//+------------------------------------------------------------------+ +//| Set the time coordinate of the specified anchor point of object | +//+------------------------------------------------------------------+ +bool CChartObject::Time(const int point,const datetime time) const + { +//--- check + if(m_chart_id==-1) + return(false); + if(point>=m_num_points) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_TIME,point,time)); + } +//+------------------------------------------------------------------+ +//| Get the price coordinate of the specified anchor point of object.| +//+------------------------------------------------------------------+ +double CChartObject::Price(const int point) const + { +//--- check + if(m_chart_id==-1) + return(EMPTY_VALUE); + if(point>=m_num_points) + return(EMPTY_VALUE); +//--- result + return(ObjectGetDouble(m_chart_id,m_name,OBJPROP_PRICE,point)); + } +//+------------------------------------------------------------------+ +//| Set the price coordinate of the specified anchor point of object.| +//+------------------------------------------------------------------+ +bool CChartObject::Price(const int point,const double price) const + { +//--- check + if(m_chart_id==-1) + return(false); + if(point>=m_num_points) + return(false); +//--- result + return(ObjectSetDouble(m_chart_id,m_name,OBJPROP_PRICE,point,price)); + } +//+------------------------------------------------------------------+ +//| Get object color | +//+------------------------------------------------------------------+ +color CChartObject::Color(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ObjectGetInteger(m_chart_id,m_name,OBJPROP_COLOR)); + } +//+------------------------------------------------------------------+ +//| Set object color | +//+------------------------------------------------------------------+ +bool CChartObject::Color(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_COLOR,new_color)); + } +//+------------------------------------------------------------------+ +//| Get style of line of object | +//+------------------------------------------------------------------+ +ENUM_LINE_STYLE CChartObject::Style(void) const + { +//--- check + if(m_chart_id==-1) + return(WRONG_VALUE); +//--- result + return((ENUM_LINE_STYLE)ObjectGetInteger(m_chart_id,m_name,OBJPROP_STYLE)); + } +//+------------------------------------------------------------------+ +//| Set style of line of object | +//+------------------------------------------------------------------+ +bool CChartObject::Style(const ENUM_LINE_STYLE new_style) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_STYLE,new_style)); + } +//+------------------------------------------------------------------+ +//| Get width of line of object | +//+------------------------------------------------------------------+ +int CChartObject::Width(void) const + { +//--- check + if(m_chart_id==-1) + return(-1); +//--- result + return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_WIDTH)); + } +//+------------------------------------------------------------------+ +//| Set width of line of object | +//+------------------------------------------------------------------+ +bool CChartObject::Width(const int new_width) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_WIDTH,new_width)); + } +//+------------------------------------------------------------------+ +//| Get the "Draw object as background" flag | +//+------------------------------------------------------------------+ +bool CChartObject::Background(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_BACK)); + } +//+------------------------------------------------------------------+ +//| Set the "Draw object as background" flag | +//+------------------------------------------------------------------+ +bool CChartObject::Background(const bool new_back) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_BACK,new_back)); + } +//+------------------------------------------------------------------+ +//| Get the "Filling" flag | +//+------------------------------------------------------------------+ +bool CChartObject::Fill(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_FILL)); + } +//+------------------------------------------------------------------+ +//| Set the "Filling" flag | +//+------------------------------------------------------------------+ +bool CChartObject::Fill(const bool new_fill) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_FILL,new_fill)); + } +//+------------------------------------------------------------------+ +//| Get the "Z-order" property | +//+------------------------------------------------------------------+ +long CChartObject::Z_Order(void) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return(ObjectGetInteger(m_chart_id,m_name,OBJPROP_ZORDER)); + } +//+------------------------------------------------------------------+ +//| Set the "Z-order" property | +//+------------------------------------------------------------------+ +bool CChartObject::Z_Order(const long value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_ZORDER,value)); + } +//+------------------------------------------------------------------+ +//| Get the "selected" flag | +//+------------------------------------------------------------------+ +bool CChartObject::Selected(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_SELECTED)); + } +//+------------------------------------------------------------------+ +//| Set the "selected" flag | +//+------------------------------------------------------------------+ +bool CChartObject::Selected(const bool new_sel) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_SELECTED,new_sel)); + } +//+------------------------------------------------------------------+ +//| Get the "selectable" flag | +//+------------------------------------------------------------------+ +bool CChartObject::Selectable(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_SELECTABLE)); + } +//+------------------------------------------------------------------+ +//| Set flag the "selectable" flag | +//+------------------------------------------------------------------+ +bool CChartObject::Selectable(const bool new_sel) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_SELECTABLE,new_sel)); + } +//+------------------------------------------------------------------+ +//| Get comment of object | +//+------------------------------------------------------------------+ +string CChartObject::Description(void) const + { +//--- check + if(m_chart_id==-1) + return(""); +//--- result + return(ObjectGetString(m_chart_id,m_name,OBJPROP_TEXT)); + } +//+------------------------------------------------------------------+ +//| Set comment of object | +//+------------------------------------------------------------------+ +bool CChartObject::Description(const string new_text) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- tune + if(new_text=="") + return(ObjectSetString(m_chart_id,m_name,OBJPROP_TEXT," ")); +//--- result + return(ObjectSetString(m_chart_id,m_name,OBJPROP_TEXT,new_text)); + } +//+------------------------------------------------------------------+ +//| Get tooltip of object | +//+------------------------------------------------------------------+ +string CChartObject::Tooltip(void) const + { +//--- check + if(m_chart_id==-1) + return(""); +//--- result + return(ObjectGetString(m_chart_id,m_name,OBJPROP_TOOLTIP)); + } +//+------------------------------------------------------------------+ +//| Set tooltip of object | +//+------------------------------------------------------------------+ +bool CChartObject::Tooltip(const string new_text) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- tune + if(new_text=="") + return(ObjectSetString(m_chart_id,m_name,OBJPROP_TOOLTIP," ")); +//--- result + return(ObjectSetString(m_chart_id,m_name,OBJPROP_TOOLTIP,new_text)); + } +//+------------------------------------------------------------------+ +//| Get the "Timeframes" (visibility) flag | +//+------------------------------------------------------------------+ +int CChartObject::Timeframes(void) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_TIMEFRAMES)); + } +//+------------------------------------------------------------------+ +//| Set the "Timeframes" (visibility) flag | +//+------------------------------------------------------------------+ +bool CChartObject::Timeframes(const int timeframes) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_TIMEFRAMES,timeframes)); + } +//+------------------------------------------------------------------+ +//| Get time of object creation | +//+------------------------------------------------------------------+ +datetime CChartObject::CreateTime(void) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return((datetime)ObjectGetInteger(m_chart_id,m_name,OBJPROP_CREATETIME)); + } +//+------------------------------------------------------------------+ +//| Get number of levels of object | +//+------------------------------------------------------------------+ +int CChartObject::LevelsCount(void) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_LEVELS)); + } +//+------------------------------------------------------------------+ +//| Set number of levels of object | +//+------------------------------------------------------------------+ +bool CChartObject::LevelsCount(const int new_count) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_LEVELS,new_count)); + } +//+------------------------------------------------------------------+ +//| Get color of the specified level of object | +//+------------------------------------------------------------------+ +color CChartObject::LevelColor(const int level) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); + if(level>=LevelsCount()) + return(CLR_NONE); +//--- result + return((color)ObjectGetInteger(m_chart_id,m_name,OBJPROP_LEVELCOLOR,level)); + } +//+------------------------------------------------------------------+ +//| Set color of the specified level of object | +//+------------------------------------------------------------------+ +bool CChartObject::LevelColor(const int level,const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); + if(level>=LevelsCount()) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_LEVELCOLOR,level,new_color)); + } +//+------------------------------------------------------------------+ +//| Get line style of the specified level of object | +//+------------------------------------------------------------------+ +ENUM_LINE_STYLE CChartObject::LevelStyle(const int level) const + { +//--- check + if(m_chart_id==-1) + return(WRONG_VALUE); + if(level>=LevelsCount()) + return(WRONG_VALUE); +//--- result + return((ENUM_LINE_STYLE)ObjectGetInteger(m_chart_id,m_name,OBJPROP_LEVELSTYLE,level)); + } +//+------------------------------------------------------------------+ +//| Set line style of the specified level of object | +//+------------------------------------------------------------------+ +bool CChartObject::LevelStyle(const int level,const ENUM_LINE_STYLE new_style) const + { +//--- check + if(m_chart_id==-1) + return(false); + if(level>=LevelsCount()) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_LEVELSTYLE,level,new_style)); + } +//+------------------------------------------------------------------+ +//| Get line width of the specified level of object | +//+------------------------------------------------------------------+ +int CChartObject::LevelWidth(const int level) const + { +//--- check + if(m_chart_id==-1) + return(-1); + if(level>=LevelsCount()) + return(-1); +//--- result + return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_LEVELWIDTH,level)); + } +//+------------------------------------------------------------------+ +//| Set line width of the specified level of object | +//+------------------------------------------------------------------+ +bool CChartObject::LevelWidth(const int level,const int new_width) const + { +//--- check + if(m_chart_id==-1) + return(false); + if(level>=LevelsCount()) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_LEVELWIDTH,level,new_width)); + } +//+------------------------------------------------------------------+ +//| Get value of the specified level of object | +//+------------------------------------------------------------------+ +double CChartObject::LevelValue(const int level) const + { +//--- check + if(m_chart_id==-1) + return(EMPTY_VALUE); + if(level>=LevelsCount()) + return(EMPTY_VALUE); +//--- result + return(ObjectGetDouble(m_chart_id,m_name,OBJPROP_LEVELVALUE,level)); + } +//+------------------------------------------------------------------+ +//| Set value of the specified level of object | +//+------------------------------------------------------------------+ +bool CChartObject::LevelValue(const int level,const double new_value) const + { +//--- check + if(m_chart_id==-1) + return(false); + if(level>=LevelsCount()) + return(false); +//--- result + return(ObjectSetDouble(m_chart_id,m_name,OBJPROP_LEVELVALUE,level,new_value)); + } +//+------------------------------------------------------------------+ +//| Get comment of of the specified level of object | +//+------------------------------------------------------------------+ +string CChartObject::LevelDescription(const int level) const + { +//--- check + if(m_chart_id==-1) + return(""); + if(level>=LevelsCount()) + return(""); +//--- result + return(ObjectGetString(m_chart_id,m_name,OBJPROP_LEVELTEXT,level)); + } +//+------------------------------------------------------------------+ +//| Set comment to the specified level of object | +//+------------------------------------------------------------------+ +bool CChartObject::LevelDescription(const int level,const string new_text) const + { +//--- checking + if(m_chart_id==-1) + return(false); + if(level>=LevelsCount()) + return(false); +//--- result + return(ObjectSetString(m_chart_id,m_name,OBJPROP_LEVELTEXT,level,new_text)); + } +//+------------------------------------------------------------------+ +//| Access function long ObjectGetInteger(...) | +//+------------------------------------------------------------------+ +long CChartObject::GetInteger(const ENUM_OBJECT_PROPERTY_INTEGER prop_id,const int modifier) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- + if(modifier==-1) + return(ObjectGetInteger(m_chart_id,m_name,prop_id)); +//--- result + return(ObjectGetInteger(m_chart_id,m_name,prop_id,modifier)); + } +//+------------------------------------------------------------------+ +//| Access function bool ObjectGetInteger(...) | +//+------------------------------------------------------------------+ +bool CChartObject::GetInteger(const ENUM_OBJECT_PROPERTY_INTEGER prop_id,const int modifier,long &value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectGetInteger(m_chart_id,m_name,prop_id,modifier,value)); + } +//+------------------------------------------------------------------+ +//| Access function ObjectSetInteger(.,modifier,.) | +//+------------------------------------------------------------------+ +bool CChartObject::SetInteger(const ENUM_OBJECT_PROPERTY_INTEGER prop_id,const int modifier,const long value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,prop_id,modifier,value)); + } +//+------------------------------------------------------------------+ +//| Access function ObjectSetInteger(...) | +//+------------------------------------------------------------------+ +bool CChartObject::SetInteger(const ENUM_OBJECT_PROPERTY_INTEGER prop_id,const long value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetInteger(m_chart_id,m_name,prop_id,value)); + } +//+------------------------------------------------------------------+ +//| Access function double ObjectGetDouble(...) | +//+------------------------------------------------------------------+ +double CChartObject::GetDouble(const ENUM_OBJECT_PROPERTY_DOUBLE prop_id,const int modifier) const + { +//--- check + if(m_chart_id==-1) + return(EMPTY_VALUE); +//--- + if(modifier==-1) + return(ObjectGetDouble(m_chart_id,m_name,prop_id)); +//--- result + return(ObjectGetDouble(m_chart_id,m_name,prop_id,modifier)); + } +//+------------------------------------------------------------------+ +//| Access function bool ObjectGetDouble(...) | +//+------------------------------------------------------------------+ +bool CChartObject::GetDouble(const ENUM_OBJECT_PROPERTY_DOUBLE prop_id,const int modifier,double &value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectGetDouble(m_chart_id,m_name,prop_id,modifier,value)); + } +//+------------------------------------------------------------------+ +//| Access function ObjectSetDouble(.,modifier,.) | +//+------------------------------------------------------------------+ +bool CChartObject::SetDouble(const ENUM_OBJECT_PROPERTY_DOUBLE prop_id,const int modifier,const double value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetDouble(m_chart_id,m_name,prop_id,modifier,value)); + } +//+------------------------------------------------------------------+ +//| Access function ObjectSetDouble(...) | +//+------------------------------------------------------------------+ +bool CChartObject::SetDouble(const ENUM_OBJECT_PROPERTY_DOUBLE prop_id,const double value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetDouble(m_chart_id,m_name,prop_id,value)); + } +//+------------------------------------------------------------------+ +//| Access function string ObjectGetString (...) | +//+------------------------------------------------------------------+ +string CChartObject::GetString(const ENUM_OBJECT_PROPERTY_STRING prop_id,const int modifier) const + { +//--- check + if(m_chart_id==-1) + return(""); +//--- + if(modifier==-1) + return(ObjectGetString(m_chart_id,m_name,prop_id)); +//--- result + return(ObjectGetString(m_chart_id,m_name,prop_id,modifier)); + } +//+------------------------------------------------------------------+ +//| Access function bool ObjectGetString(...) | +//+------------------------------------------------------------------+ +bool CChartObject::GetString(const ENUM_OBJECT_PROPERTY_STRING prop_id,const int modifier,string &value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectGetString(m_chart_id,m_name,prop_id,modifier,value)); + } +//+------------------------------------------------------------------+ +//| Access function ObjectSetString(.,modifier,.) | +//+------------------------------------------------------------------+ +bool CChartObject::SetString(const ENUM_OBJECT_PROPERTY_STRING prop_id,const int modifier,const string value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetString(m_chart_id,m_name,prop_id,modifier,value)); + } +//+------------------------------------------------------------------+ +//| Access function ObjectSetString(...) | +//+------------------------------------------------------------------+ +bool CChartObject::SetString(const ENUM_OBJECT_PROPERTY_STRING prop_id,const string value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ObjectSetString(m_chart_id,m_name,prop_id,value)); + } +//+------------------------------------------------------------------+ +//| Relative movement of object | +//+------------------------------------------------------------------+ +bool CChartObject::ShiftObject(const datetime d_time,const double d_price) const + { + bool result=true; + int i; +//--- check + if(m_chart_id==-1) + return(false); +//--- move + for(i=0;i=m_num_points) + return(false); +//--- move + datetime time=(datetime)ObjectGetInteger(m_chart_id,m_name,OBJPROP_TIME,point); + double price=ObjectGetDouble(m_chart_id,m_name,OBJPROP_PRICE,point); +//--- result + return(ObjectMove(m_chart_id,m_name,point,time+d_time,price+d_price)); + } +//+------------------------------------------------------------------+ +//| Writing object parameters to file | +//+------------------------------------------------------------------+ +bool CChartObject::Save(const int file_handle) + { + int i,len; + int levels; + string str; +//--- check + if(file_handle==INVALID_HANDLE || m_chart_id==-1) + return(false); +//--- write start marker - 0xFFFFFFFFFFFFFFFF + if(FileWriteLong(file_handle,-1)!=sizeof(long)) + return(false); +//--- write object type + if(FileWriteInteger(file_handle,Type(),INT_VALUE)!=INT_VALUE) + return(false); +//--- write object name + str=ObjectGetString(m_chart_id,m_name,OBJPROP_NAME); + len=StringLen(str); + if(FileWriteInteger(file_handle,len,INT_VALUE)!=INT_VALUE) + return(false); + if(len!=0) if(FileWriteString(file_handle,str,len)!=len) + return(false); +//--- write object color + if(FileWriteLong(file_handle,ObjectGetInteger(m_chart_id,m_name,OBJPROP_COLOR))!=sizeof(long)) + return(false); +//--- write object line style + if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_STYLE))!=sizeof(int)) + return(false); +//--- write object line width + if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_WIDTH))!=sizeof(int)) + return(false); +//--- write the property value "Background" + if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_BACK),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write the property value "Selectable" + if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_SELECTABLE),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write the property value "Timeframes" + if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_TIMEFRAMES),INT_VALUE)!=sizeof(int)) + return(false); +//--- write comment + str=ObjectGetString(m_chart_id,m_name,OBJPROP_TEXT); + len=StringLen(str); + if(FileWriteInteger(file_handle,len,INT_VALUE)!=INT_VALUE) + return(false); + if(len!=0) if(FileWriteString(file_handle,str,len)!=len) + return(false); +//--- write number of points + if(FileWriteInteger(file_handle,m_num_points,INT_VALUE)!=INT_VALUE) + return(false); +//--- write points + for(i=0;i +#include +#include +//+------------------------------------------------------------------+ +//| Class CChartObjectPanel. | +//| Purpose: Class for grouping objects for managing a chart | +//+------------------------------------------------------------------+ +class CChartObjectPanel : public CChartObjectButton + { +protected: + CArrayObj m_attachment; // array of attached objects + CArrayInt m_dX; // array of dX attached objects + CArrayInt m_dY; // array of dY attached objects + bool m_expanded; // collapsed/expanded flag + +public: + CChartObjectPanel(); + ~CChartObjectPanel(); + //--- method for attaching objects + bool Attach(CChartObjectLabel *chart_object); + bool X_Distance(const int X); + int X_Distance(void) const { return(CChartObjectButton::X_Distance()); } + bool Y_Distance(const int Y); + int Y_Distance(void) const { return(CChartObjectButton::Y_Distance()); } + int X_Size() const; + int X_Size(const int Y) const { return(CChartObjectButton::X_Size()); } + int Y_Size() const; + int Y_Size(const int Y) const { return(CChartObjectButton::Y_Size()); } + + int Timeframes(void) const { return(CChartObjectButton::Timeframes()); } + virtual bool Timeframes(const int timeframes); + bool State(const bool state); + bool State(void) const { return(CChartObjectButton::State()); } + bool CheckState(); + +protected: + }; +//+------------------------------------------------------------------+ +//| Constructor | +//+------------------------------------------------------------------+ +void CChartObjectPanel::CChartObjectPanel(void) : m_expanded(true) + { + } +//+------------------------------------------------------------------+ +//| Destructor. | +//+------------------------------------------------------------------+ +void CChartObjectPanel::~CChartObjectPanel(void) + { +//--- All objects added by the method Add(), deleted automatically + } +//+------------------------------------------------------------------+ +//| Method Attach | +//+------------------------------------------------------------------+ +bool CChartObjectPanel::Attach(CChartObjectLabel *chart_object) + { + if(m_attachment.Add(chart_object)) + { + int x,y; + x=chart_object.X_Distance(); + m_dX.Add(chart_object.X_Distance()); + x+=X_Distance(); + chart_object.X_Distance(X_Distance()+chart_object.X_Distance()); + y=CChartObjectButton::Y_Size(); + y+=chart_object.Y_Distance(); + m_dY.Add(chart_object.Y_Distance()+CChartObjectButton::Y_Size()+2); + chart_object.Y_Distance(Y_Distance()+chart_object.Y_Distance()+CChartObjectButton::Y_Size()+2); + return(true); + } +//--- + return(false); + } +//+------------------------------------------------------------------+ +//| Method X_Distance | +//+------------------------------------------------------------------+ +bool CChartObjectPanel::X_Distance(const int X) + { + CChartObjectLabel *chart_object; +//--- + for(int i=0;i +//+------------------------------------------------------------------+ +//| Class CChart. | +//| Purpose: Class of the "Chart" object. | +//| Derives from class CObject. | +//+------------------------------------------------------------------+ +class CChart : public CObject + { +protected: + long m_chart_id; // chart identifier +public: + CChart(void); + ~CChart(void); + //--- methods of access to protected data + long ChartId(void) const { return(m_chart_id); } + //--- method of identifying the object + virtual int Type(void) const { return(0x1111); } + //--- methods of access to properties of the chart + //--- common properties + ENUM_CHART_MODE Mode(void) const; + bool Mode(const ENUM_CHART_MODE mode) const; + bool Foreground(void) const; + bool Foreground(const bool foreground) const; + bool Shift(void) const; + bool Shift(const bool shift) const; + double ShiftSize(void) const; + bool ShiftSize(double shift) const; + bool AutoScroll(void) const; + bool AutoScroll(const bool auto_scroll) const; + int Scale(void) const; + bool Scale(int scale) const; + bool ScaleFix(void) const; + bool ScaleFix(const bool scale_fix) const; + bool ScaleFix_11(void) const; + bool ScaleFix_11(const bool scale_fix_11) const; + double FixedMax(void) const; + bool FixedMax(const double fixed_max) const; + double FixedMin(void) const; + bool FixedMin(const double fixed_min) const; + bool ScalePPB(void) const; + bool ScalePPB(const bool scale_ppb) const; + double PointsPerBar(void) const; + bool PointsPerBar(const double points_per_bar) const; + //--- show properties + bool ShowOHLC(void) const; + bool ShowOHLC(const bool show) const; + bool ShowLineBid(void) const; + bool ShowLineBid(const bool show) const; + bool ShowLineAsk(void) const; + bool ShowLineAsk(const bool show) const; + bool ShowLastLine(void) const; + bool ShowLastLine(const bool show) const; + bool ShowPeriodSep(void) const; + bool ShowPeriodSep(const bool show) const; + bool ShowGrid(void) const; + bool ShowGrid(const bool show) const; + ENUM_CHART_VOLUME_MODE ShowVolumes(void) const; + bool ShowVolumes(const ENUM_CHART_VOLUME_MODE show) const; + bool ShowObjectDescr(void) const; + bool ShowObjectDescr(const bool show) const; + bool ShowDateScale(const bool show) const; + bool ShowPriceScale(const bool show) const; + //--- color properties + color ColorBackground(void) const; + bool ColorBackground(const color new_color) const; + color ColorForeground(void) const; + bool ColorForeground(const color new_color) const; + color ColorGrid(void) const; + bool ColorGrid(const color new_color) const; + color ColorBarUp(void) const; + bool ColorBarUp(const color new_color) const; + color ColorBarDown(void) const; + bool ColorBarDown(const color new_color) const; + color ColorCandleBull(void) const; + bool ColorCandleBull(const color new_color) const; + color ColorCandleBear(void) const; + bool ColorCandleBear(const color new_color) const; + color ColorChartLine(void) const; + bool ColorChartLine(const color new_color) const; + color ColorVolumes(void) const; + bool ColorVolumes(const color new_color) const; + color ColorLineBid(void) const; + bool ColorLineBid(const color new_color) const; + color ColorLineAsk(void) const; + bool ColorLineAsk(const color new_color) const; + color ColorLineLast(void) const; + bool ColorLineLast(const color new_color) const; + color ColorStopLevels(void) const; + bool ColorStopLevels(const color new_color) const; + //--- other properties + bool BringToTop(void) const; + bool EventObjectCreate(const bool flag=true) const; + bool EventObjectDelete(const bool flag=true) const; + bool EventMouseMove(const bool flag=true) const; + bool MouseScroll(const bool flag=true) const; + //--- methods of access to READ ONLY properties of the chart + int VisibleBars(void) const; + int WindowsTotal(void) const; + bool WindowIsVisible(const int num) const; + int WindowHandle(void) const; + int FirstVisibleBar(void) const; + int WidthInBars(void) const; + int WidthInPixels(void) const; + int HeightInPixels(const int num) const; + int SubwindowY(const int num) const; + double PriceMin(const int num) const; + double PriceMax(const int num) const; + bool IsObject(void) const; + //--- methods of binding chart + void Attach(void) { m_chart_id=ChartID(); } + void Attach(const long chart) { m_chart_id=chart; } + void FirstChart(void) { m_chart_id=ChartFirst(); } + void NextChart(void) { m_chart_id=ChartNext(m_chart_id); } + long Open(const string symbol_name,const ENUM_TIMEFRAMES timeframe); + void Detach(void) { m_chart_id=-1; } + void Close(void); + //--- navigation method + bool Navigate(const ENUM_CHART_POSITION position,const int shift=0) const; + //--- methods of access to the API functions of MQL5 + string Symbol(void) const { return(ChartSymbol(m_chart_id)); } + ENUM_TIMEFRAMES Period(void) const { return(ChartPeriod(m_chart_id)); } + void Redraw(void) const { ChartRedraw(m_chart_id); } + long GetInteger(const ENUM_CHART_PROPERTY_INTEGER prop_id,const int sub_window=0) const; + bool GetInteger(const ENUM_CHART_PROPERTY_INTEGER prop_id,const int sub_window,long &value) const; + bool SetInteger(const ENUM_CHART_PROPERTY_INTEGER prop_id,const long value) const; + double GetDouble(const ENUM_CHART_PROPERTY_DOUBLE prop_id,const int sub_window=0) const; + bool GetDouble(const ENUM_CHART_PROPERTY_DOUBLE prop_id,const int sub_window,double &value) const; + bool SetDouble(const ENUM_CHART_PROPERTY_DOUBLE prop_id,const double value) const; + string GetString(const ENUM_CHART_PROPERTY_STRING prop_id) const; + bool GetString(const ENUM_CHART_PROPERTY_STRING prop_id,string &value) const; + bool SetString(const ENUM_CHART_PROPERTY_STRING prop_id,const string value) const; + bool SetSymbolPeriod(const string symbol,const ENUM_TIMEFRAMES period) const; + bool ApplyTemplate(const string filename) const; + bool ScreenShot(const string filename,const int width,const int height, + const ENUM_ALIGN_MODE align_mode=ALIGN_RIGHT) const; + int WindowOnDropped(void) const; + double PriceOnDropped(void) const; + datetime TimeOnDropped(void) const; + int XOnDropped(void) const; + int YOnDropped(void) const; + //--- methods for working with indicators + bool IndicatorAdd(const int subwin,const int handle) const; + bool IndicatorDelete(const int subwin,const string name) const; + int IndicatorsTotal(const int subwin) const; + string IndicatorName(const int subwin,const int index) const; + //--- methods for working with files + virtual bool Save(const int file_handle); + virtual bool Load(const int file_handle); + }; +//+------------------------------------------------------------------+ +//| Constructor | +//+------------------------------------------------------------------+ +CChart::CChart(void) : m_chart_id(-1) + { + } +//+------------------------------------------------------------------+ +//| Destructor | +//+------------------------------------------------------------------+ +CChart::~CChart(void) + { + if(m_chart_id!=-1) + Close(); + } +//+------------------------------------------------------------------+ +//| Opening chart | +//+------------------------------------------------------------------+ +long CChart::Open(const string symbol_name,const ENUM_TIMEFRAMES timeframe) + { + m_chart_id=ChartOpen(symbol_name,timeframe); + if(m_chart_id==0) + m_chart_id=-1; + return(m_chart_id); + } +//+------------------------------------------------------------------+ +//| Get the type of representation of chart | +//+------------------------------------------------------------------+ +ENUM_CHART_MODE CChart::Mode(void) const + { +//--- check + if(m_chart_id==-1) + return(WRONG_VALUE); +//--- result + return((ENUM_CHART_MODE)ChartGetInteger(m_chart_id,CHART_MODE)); + } +//+------------------------------------------------------------------+ +//| Set the type of representation chart | +//+------------------------------------------------------------------+ +bool CChart::Mode(const ENUM_CHART_MODE mode) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_MODE,mode)); + } +//+------------------------------------------------------------------+ +//| Get value of the "Foreground" property | +//+------------------------------------------------------------------+ +bool CChart::Foreground(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_FOREGROUND)); + } +//+------------------------------------------------------------------+ +//| Set value of the "Foreground" property | +//+------------------------------------------------------------------+ +bool CChart::Foreground(const bool foreground) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_FOREGROUND,foreground)); + } +//+------------------------------------------------------------------+ +//| Get value of the "Shift" property | +//+------------------------------------------------------------------+ +bool CChart::Shift(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_SHIFT)); + } +//+------------------------------------------------------------------+ +//| Set value of the "Shift"property | +//+------------------------------------------------------------------+ +bool CChart::Shift(const bool shift) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SHIFT,shift)); + } +//+------------------------------------------------------------------+ +//| Get value of the "ShiftSize" property | +//+------------------------------------------------------------------+ +double CChart::ShiftSize(void) const + { +//--- check + if(m_chart_id==-1) + return(DBL_MAX); +//--- result + return(ChartGetDouble(m_chart_id,CHART_SHIFT_SIZE)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ShiftSize" property | +//+------------------------------------------------------------------+ +bool CChart::ShiftSize(double shift) const + { +//--- check + if(m_chart_id==-1) + return(false); + if(shift<10) + shift=10; + if(shift>50) + shift=50; +//--- result + return(ChartSetDouble(m_chart_id,CHART_SHIFT_SIZE,shift)); + } +//+------------------------------------------------------------------+ +//| Get value of the "AutoScroll" property | +//+------------------------------------------------------------------+ +bool CChart::AutoScroll(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_AUTOSCROLL)); + } +//+------------------------------------------------------------------+ +//| Set value of the "AutoScroll" property | +//+------------------------------------------------------------------+ +bool CChart::AutoScroll(const bool auto_scroll) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_AUTOSCROLL,auto_scroll)); + } +//+------------------------------------------------------------------+ +//| Get value of the "Scale" property | +//+------------------------------------------------------------------+ +int CChart::Scale(void) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return((int)ChartGetInteger(m_chart_id,CHART_SCALE)); + } +//+------------------------------------------------------------------+ +//| Set value of the "Scale" property | +//+------------------------------------------------------------------+ +bool CChart::Scale(int shift) const + { +//--- check + if(m_chart_id==-1) + return(false); + if(shift<0) + shift=0; + if(shift>32) + shift=32; +//--- result + return(ChartSetInteger(m_chart_id,CHART_SCALE,shift)); + } +//+------------------------------------------------------------------+ +//| Get value of the "ScaleFix" property | +//+------------------------------------------------------------------+ +bool CChart::ScaleFix(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_SCALEFIX)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ScaleFix" property | +//+------------------------------------------------------------------+ +bool CChart::ScaleFix(const bool scale_fix) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SCALEFIX,scale_fix)); + } +//+------------------------------------------------------------------+ +//| Get value of the "ScaleFix_11" property | +//+------------------------------------------------------------------+ +bool CChart::ScaleFix_11(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_SCALEFIX_11)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ScaleFix_11" property | +//+------------------------------------------------------------------+ +bool CChart::ScaleFix_11(const bool scale_fix_11) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SCALEFIX_11,scale_fix_11)); + } +//+------------------------------------------------------------------+ +//| Get value of the "FixedMax" property | +//+------------------------------------------------------------------+ +double CChart::FixedMax(void) const + { +//--- check + if(m_chart_id==-1) + return(EMPTY_VALUE); +//--- result + return(ChartGetDouble(m_chart_id,CHART_FIXED_MAX)); + } +//+------------------------------------------------------------------+ +//| Set value of the "FixedMax" property | +//+------------------------------------------------------------------+ +bool CChart::FixedMax(const double fixed_max) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetDouble(m_chart_id,CHART_FIXED_MAX,fixed_max)); + } +//+------------------------------------------------------------------+ +//| Get value of the "FixedMin" property | +//+------------------------------------------------------------------+ +double CChart::FixedMin(void) const + { +//--- check + if(m_chart_id==-1) + return(EMPTY_VALUE); +//--- result + return(ChartGetDouble(m_chart_id,CHART_FIXED_MIN)); + } +//+------------------------------------------------------------------+ +//| Set value of the "FixedMin" property | +//+------------------------------------------------------------------+ +bool CChart::FixedMin(const double fixed_min) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetDouble(m_chart_id,CHART_FIXED_MIN,fixed_min)); + } +//+------------------------------------------------------------------+ +//| Get value of the "ScalePointsPerBar" property | +//+------------------------------------------------------------------+ +bool CChart::ScalePPB(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_SCALE_PT_PER_BAR)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ScalePointsPerBar" property | +//+------------------------------------------------------------------+ +bool CChart::ScalePPB(const bool scale_ppb) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SCALE_PT_PER_BAR,scale_ppb)); + } +//+------------------------------------------------------------------+ +//| Get value of the "PointsPerBar" property | +//+------------------------------------------------------------------+ +double CChart::PointsPerBar(void) const + { +//--- check + if(m_chart_id==-1) + return(EMPTY_VALUE); +//--- result + return(ChartGetDouble(m_chart_id,CHART_POINTS_PER_BAR)); + } +//+------------------------------------------------------------------+ +//| Set value of the "PointsPerBar" property | +//+------------------------------------------------------------------+ +bool CChart::PointsPerBar(const double points_per_bar) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetDouble(m_chart_id,CHART_POINTS_PER_BAR,points_per_bar)); + } +//+------------------------------------------------------------------+ +//| Get value of the "ShowOHLC" property | +//+------------------------------------------------------------------+ +bool CChart::ShowOHLC(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_SHOW_OHLC)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ShowOHLC" property | +//+------------------------------------------------------------------+ +bool CChart::ShowOHLC(const bool show) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SHOW_OHLC,show)); + } +//+------------------------------------------------------------------+ +//| Get value of the "ShowLineBid" property | +//+------------------------------------------------------------------+ +bool CChart::ShowLineBid(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_SHOW_BID_LINE)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ShowLineBid" property | +//+------------------------------------------------------------------+ +bool CChart::ShowLineBid(const bool show) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SHOW_BID_LINE,show)); + } +//+------------------------------------------------------------------+ +//| Get value of the "ShowLineAsk" property | +//+------------------------------------------------------------------+ +bool CChart::ShowLineAsk(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_SHOW_ASK_LINE)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ShowLineAsk" property | +//+------------------------------------------------------------------+ +bool CChart::ShowLineAsk(const bool show) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SHOW_ASK_LINE,show)); + } +//+------------------------------------------------------------------+ +//| Get value of the "ShowLastLine" property | +//+------------------------------------------------------------------+ +bool CChart::ShowLastLine(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_SHOW_LAST_LINE)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ShowLastLine" property | +//+------------------------------------------------------------------+ +bool CChart::ShowLastLine(const bool show) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SHOW_LAST_LINE,show)); + } +//+------------------------------------------------------------------+ +//| Get value of the "ShowPeriodSep" property | +//+------------------------------------------------------------------+ +bool CChart::ShowPeriodSep(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_SHOW_PERIOD_SEP)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ShowPeriodSep" property | +//+------------------------------------------------------------------+ +bool CChart::ShowPeriodSep(const bool show) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SHOW_PERIOD_SEP,show)); + } +//+------------------------------------------------------------------+ +//| Get value of the "ShowGrid" property | +//+------------------------------------------------------------------+ +bool CChart::ShowGrid(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_SHOW_GRID)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ShowGrid" property | +//+------------------------------------------------------------------+ +bool CChart::ShowGrid(const bool show) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SHOW_GRID,show)); + } +//+------------------------------------------------------------------+ +//| Get value of the "ShowVolumes" property | +//+------------------------------------------------------------------+ +ENUM_CHART_VOLUME_MODE CChart::ShowVolumes(void) const + { +//--- check + if(m_chart_id==-1) + return(WRONG_VALUE); +//--- result + return((ENUM_CHART_VOLUME_MODE)ChartGetInteger(m_chart_id,CHART_SHOW_VOLUMES)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ShowVolumes" property | +//+------------------------------------------------------------------+ +bool CChart::ShowVolumes(const ENUM_CHART_VOLUME_MODE show) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SHOW_VOLUMES,show)); + } +//+------------------------------------------------------------------+ +//| Get value of the "ShowObjectDescr" property | +//+------------------------------------------------------------------+ +bool CChart::ShowObjectDescr(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_SHOW_OBJECT_DESCR)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ShowObjectDescr" property | +//+------------------------------------------------------------------+ +bool CChart::ShowObjectDescr(const bool show) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SHOW_OBJECT_DESCR,show)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ShowDateScale" property | +//+------------------------------------------------------------------+ +bool CChart::ShowDateScale(const bool show) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SHOW_DATE_SCALE,show)); + } +//+------------------------------------------------------------------+ +//| Set value of the "ShowPriceScale" property | +//+------------------------------------------------------------------+ +bool CChart::ShowPriceScale(const bool show) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_SHOW_PRICE_SCALE,show)); + } +//+------------------------------------------------------------------+ +//| Get color value of the "Background" property | +//+------------------------------------------------------------------+ +color CChart::ColorBackground(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ChartGetInteger(m_chart_id,CHART_COLOR_BACKGROUND)); + } +//+------------------------------------------------------------------+ +//| Set color value of the "Background" property | +//+------------------------------------------------------------------+ +bool CChart::ColorBackground(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_COLOR_BACKGROUND,new_color)); + } +//+------------------------------------------------------------------+ +//| Get color value of the "Foreground" property | +//+------------------------------------------------------------------+ +color CChart::ColorForeground(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ChartGetInteger(m_chart_id,CHART_COLOR_FOREGROUND)); + } +//+------------------------------------------------------------------+ +//| Set color value for the "Foreground" property | +//+------------------------------------------------------------------+ +bool CChart::ColorForeground(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_COLOR_FOREGROUND,new_color)); + } +//+------------------------------------------------------------------+ +//| Get color value of the "Grid" property | +//+------------------------------------------------------------------+ +color CChart::ColorGrid(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ChartGetInteger(m_chart_id,CHART_COLOR_GRID)); + } +//+------------------------------------------------------------------+ +//| Set color value for the "Grid" property | +//+------------------------------------------------------------------+ +bool CChart::ColorGrid(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_COLOR_GRID,new_color)); + } +//+------------------------------------------------------------------+ +//| Get color value of the "Bar Up" property | +//+------------------------------------------------------------------+ +color CChart::ColorBarUp(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ChartGetInteger(m_chart_id,CHART_COLOR_CHART_UP)); + } +//+------------------------------------------------------------------+ +//| Set color value of the "Bar Up" property | +//+------------------------------------------------------------------+ +bool CChart::ColorBarUp(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_COLOR_CHART_UP,new_color)); + } +//+------------------------------------------------------------------+ +//| Get color value of the "Bar Down" property | +//+------------------------------------------------------------------+ +color CChart::ColorBarDown(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ChartGetInteger(m_chart_id,CHART_COLOR_CHART_DOWN)); + } +//+------------------------------------------------------------------+ +//| Set color value of the "Bar Down" property | +//+------------------------------------------------------------------+ +bool CChart::ColorBarDown(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_COLOR_CHART_DOWN,new_color)); + } +//+------------------------------------------------------------------+ +//| Get color value of the "Candle Bull" property | +//+------------------------------------------------------------------+ +color CChart::ColorCandleBull(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ChartGetInteger(m_chart_id,CHART_COLOR_CANDLE_BULL)); + } +//+------------------------------------------------------------------+ +//| Set color value of the "Candle Bull" property | +//+------------------------------------------------------------------+ +bool CChart::ColorCandleBull(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_COLOR_CANDLE_BULL,new_color)); + } +//+------------------------------------------------------------------+ +//| Get color value of the "Candle Bear" property | +//+------------------------------------------------------------------+ +color CChart::ColorCandleBear(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ChartGetInteger(m_chart_id,CHART_COLOR_CANDLE_BEAR)); + } +//+------------------------------------------------------------------+ +//| Set color value of the "Candle Bear" property | +//+------------------------------------------------------------------+ +bool CChart::ColorCandleBear(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_COLOR_CANDLE_BEAR,new_color)); + } +//+------------------------------------------------------------------+ +//| Get color value of the "Chart Line" property | +//+------------------------------------------------------------------+ +color CChart::ColorChartLine(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ChartGetInteger(m_chart_id,CHART_COLOR_CHART_LINE)); + } +//+------------------------------------------------------------------+ +//| Set color value of the "Chart Line" property | +//+------------------------------------------------------------------+ +bool CChart::ColorChartLine(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_COLOR_CHART_LINE,new_color)); + } +//+------------------------------------------------------------------+ +//| Get color value of the "Volumes" property | +//+------------------------------------------------------------------+ +color CChart::ColorVolumes(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ChartGetInteger(m_chart_id,CHART_COLOR_VOLUME)); + } +//+------------------------------------------------------------------+ +//| Set color value of the "Volumes" property | +//+------------------------------------------------------------------+ +bool CChart::ColorVolumes(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_COLOR_VOLUME,new_color)); + } +//+------------------------------------------------------------------+ +//| Get color value of the "Line Bid" property | +//+------------------------------------------------------------------+ +color CChart::ColorLineBid(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ChartGetInteger(m_chart_id,CHART_COLOR_BID)); + } +//+------------------------------------------------------------------+ +//| Set color value of the "Line Bid" property | +//+------------------------------------------------------------------+ +bool CChart::ColorLineBid(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_COLOR_BID,new_color)); + } +//+------------------------------------------------------------------+ +//| Get color value of the "Line Ask" property | +//+------------------------------------------------------------------+ +color CChart::ColorLineAsk(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ChartGetInteger(m_chart_id,CHART_COLOR_ASK)); + } +//+------------------------------------------------------------------+ +//| Set color value of the "Line Ask" property | +//+------------------------------------------------------------------+ +bool CChart::ColorLineAsk(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_COLOR_ASK,new_color)); + } +//+------------------------------------------------------------------+ +//| Get color value of the "Line Last" property | +//+------------------------------------------------------------------+ +color CChart::ColorLineLast(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ChartGetInteger(m_chart_id,CHART_COLOR_LAST)); + } +//+------------------------------------------------------------------+ +//| Set color value of the "Line Last" property | +//+------------------------------------------------------------------+ +bool CChart::ColorLineLast(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_COLOR_LAST,new_color)); + } +//+------------------------------------------------------------------+ +//| Get color value of the "Stop Levels" property | +//+------------------------------------------------------------------+ +color CChart::ColorStopLevels(void) const + { +//--- check + if(m_chart_id==-1) + return(CLR_NONE); +//--- result + return((color)ChartGetInteger(m_chart_id,CHART_COLOR_STOP_LEVEL)); + } +//+------------------------------------------------------------------+ +//| Set color value of the "Stop Levels" property | +//+------------------------------------------------------------------+ +bool CChart::ColorStopLevels(const color new_color) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_COLOR_STOP_LEVEL,new_color)); + } +//+------------------------------------------------------------------+ +//| Shows chart always on top | +//+------------------------------------------------------------------+ +bool CChart::BringToTop(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_BRING_TO_TOP,true)); + } +//+------------------------------------------------------------------+ +//| Sets flag to generate event of creating objects | +//+------------------------------------------------------------------+ +bool CChart::EventObjectCreate(const bool flag) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_EVENT_OBJECT_CREATE,flag)); + } +//+------------------------------------------------------------------+ +//| Sets flag to generate event of deleting objects | +//+------------------------------------------------------------------+ +bool CChart::EventObjectDelete(const bool flag) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_EVENT_OBJECT_DELETE,flag)); + } +//+------------------------------------------------------------------+ +//| Sets flag to generate event of moving mouse cursor | +//+------------------------------------------------------------------+ +bool CChart::EventMouseMove(const bool flag) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_EVENT_MOUSE_MOVE,flag)); + } +//+------------------------------------------------------------------+ +//| Sets flag to mouse scrolling | +//+------------------------------------------------------------------+ +bool CChart::MouseScroll(const bool flag) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetInteger(m_chart_id,CHART_MOUSE_SCROLL,flag)); + } +//+------------------------------------------------------------------+ +//| Get value of the "VisibleBars" property | +//+------------------------------------------------------------------+ +int CChart::VisibleBars(void) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return((int)ChartGetInteger(m_chart_id,CHART_WIDTH_IN_BARS)); + } +//+------------------------------------------------------------------+ +//| Get value of the "WindowsTotal" property | +//+------------------------------------------------------------------+ +int CChart::WindowsTotal(void) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return((int)ChartGetInteger(m_chart_id,CHART_WINDOWS_TOTAL)); + } +//+------------------------------------------------------------------+ +//| Get value of the "WindowIsVisible" property | +//+------------------------------------------------------------------+ +bool CChart::WindowIsVisible(const int num) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_WINDOW_IS_VISIBLE,num)); + } +//+------------------------------------------------------------------+ +//| Get value of the "WindowHandle" property | +//+------------------------------------------------------------------+ +int CChart::WindowHandle(void) const + { +//--- check + if(m_chart_id==-1) + return(INVALID_HANDLE); +//--- result + return((int)ChartGetInteger(m_chart_id,CHART_WINDOW_HANDLE)); + } +//+------------------------------------------------------------------+ +//| Get value of the "FirstVisibleBar" property | +//+------------------------------------------------------------------+ +int CChart::FirstVisibleBar(void) const + { +//--- check + if(m_chart_id==-1) + return(-1); +//--- result + return((int)ChartGetInteger(m_chart_id,CHART_FIRST_VISIBLE_BAR)); + } +//+------------------------------------------------------------------+ +//| Get value of the "WidthInBars" property | +//+------------------------------------------------------------------+ +int CChart::WidthInBars(void) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return((int)ChartGetInteger(m_chart_id,CHART_WIDTH_IN_BARS)); + } +//+------------------------------------------------------------------+ +//| Get value of the "WidthInPixels" property | +//+------------------------------------------------------------------+ +int CChart::WidthInPixels(void) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return((int)ChartGetInteger(m_chart_id,CHART_WIDTH_IN_PIXELS)); + } +//+------------------------------------------------------------------+ +//| Get value of the "HeightInPixels" property | +//+------------------------------------------------------------------+ +int CChart::HeightInPixels(const int num) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return((int)ChartGetInteger(m_chart_id,CHART_HEIGHT_IN_PIXELS,num)); + } +//+------------------------------------------------------------------+ +//| Get value of the "WindowYDistance" property | +//+------------------------------------------------------------------+ +int CChart::SubwindowY(const int num) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return((int)ChartGetInteger(m_chart_id,CHART_WINDOW_YDISTANCE,num)); + } +//+------------------------------------------------------------------+ +//| Get value of the "PriceMin" property | +//+------------------------------------------------------------------+ +double CChart::PriceMin(const int num) const + { +//--- check + if(m_chart_id==-1) + return(EMPTY_VALUE); +//--- result + return(ChartGetDouble(m_chart_id,CHART_PRICE_MIN,num)); + } +//+------------------------------------------------------------------+ +//| Get value of the "PriceMax" property | +//+------------------------------------------------------------------+ +double CChart::PriceMax(const int num) const + { +//--- check + if(m_chart_id==-1) + return(EMPTY_VALUE); +//--- result + return(ChartGetDouble(m_chart_id,CHART_PRICE_MAX,num)); + } +//+------------------------------------------------------------------+ +//| Get value of the "IsObject" property | +//+------------------------------------------------------------------+ +bool CChart::IsObject(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return((bool)ChartGetInteger(m_chart_id,CHART_IS_OBJECT)); + } +//+------------------------------------------------------------------+ +//| Chart close | +//+------------------------------------------------------------------+ +void CChart::Close(void) + { + if(m_chart_id!=-1) + { + ChartClose(m_chart_id); + m_chart_id=-1; + } + } +//+------------------------------------------------------------------+ +//| Chart navigation | +//+------------------------------------------------------------------+ +bool CChart::Navigate(const ENUM_CHART_POSITION position,const int shift) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartNavigate(m_chart_id,position,shift)); + } +//+------------------------------------------------------------------+ +//| Access functions long ChartGetInteger(...) | +//+------------------------------------------------------------------+ +long CChart::GetInteger(const ENUM_CHART_PROPERTY_INTEGER prop_id,const int subwindow) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return(ChartGetInteger(m_chart_id,prop_id,subwindow)); + } +//+------------------------------------------------------------------+ +//| Access function bool ChartGetInteger(...) | +//+------------------------------------------------------------------+ +bool CChart::GetInteger(const ENUM_CHART_PROPERTY_INTEGER prop_id,const int subwindow,long &value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartGetInteger(m_chart_id,prop_id,subwindow,value)); + } +//+------------------------------------------------------------------+ +//| Access function ChartSetInteger(...) | +//+------------------------------------------------------------------+ +bool CChart::SetInteger(const ENUM_CHART_PROPERTY_INTEGER prop_id,const long value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- + return(ChartSetInteger(m_chart_id,prop_id,value)); + } +//+------------------------------------------------------------------+ +//| Access function double ChartGetDouble(...) | +//+------------------------------------------------------------------+ +double CChart::GetDouble(const ENUM_CHART_PROPERTY_DOUBLE prop_id,const int subwindow) const + { +//--- check + if(m_chart_id==-1) + return(EMPTY_VALUE); +//--- result + return(ChartGetDouble(m_chart_id,prop_id,subwindow)); + } +//+------------------------------------------------------------------+ +//| Access function bool ChartGetDouble(...) | +//+------------------------------------------------------------------+ +bool CChart::GetDouble(const ENUM_CHART_PROPERTY_DOUBLE prop_id,const int subwindow,double &value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartGetDouble(m_chart_id,prop_id,subwindow,value)); + } +//+------------------------------------------------------------------+ +//| Access function ChartSetDouble(...) | +//+------------------------------------------------------------------+ +bool CChart::SetDouble(const ENUM_CHART_PROPERTY_DOUBLE prop_id,const double value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetDouble(m_chart_id,prop_id,value)); + } +//+------------------------------------------------------------------+ +//| Access function string ChartGetString(...) | +//+------------------------------------------------------------------+ +string CChart::GetString(const ENUM_CHART_PROPERTY_STRING prop_id) const + { +//--- check + if(m_chart_id==-1) + return(""); +//--- result + return(ChartGetString(m_chart_id,prop_id)); + } +//+------------------------------------------------------------------+ +//| Access functions bool ChartGetString(...) | +//+------------------------------------------------------------------+ +bool CChart::GetString(const ENUM_CHART_PROPERTY_STRING prop_id,string &value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartGetString(m_chart_id,prop_id,value)); + } +//+------------------------------------------------------------------+ +//| Access function ChartSetString(...) | +//+------------------------------------------------------------------+ +bool CChart::SetString(const ENUM_CHART_PROPERTY_STRING prop_id,const string value) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetString(m_chart_id,prop_id,value)); + } +//+------------------------------------------------------------------+ +//| Access function ChartSetSymbolPeriod(...) | +//+------------------------------------------------------------------+ +bool CChart::SetSymbolPeriod(const string symbol,const ENUM_TIMEFRAMES period) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartSetSymbolPeriod(m_chart_id,symbol,period)); + } +//+------------------------------------------------------------------+ +//| Access function ChartApplyTemplate(...) | +//+------------------------------------------------------------------+ +bool CChart::ApplyTemplate(const string filename) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartApplyTemplate(m_chart_id,filename)); + } +//+------------------------------------------------------------------+ +//| Access function ChartScreenShot(...) | +//+------------------------------------------------------------------+ +bool CChart::ScreenShot(const string filename,const int width,const int height,const ENUM_ALIGN_MODE align_mode) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartScreenShot(m_chart_id,filename,width,height,align_mode)); + } +//+------------------------------------------------------------------+ +//| Access function WindowOnDropped() | +//+------------------------------------------------------------------+ +int CChart::WindowOnDropped(void) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return(ChartWindowOnDropped()); + } +//+------------------------------------------------------------------+ +//| Access function PriceOnDropped() | +//+------------------------------------------------------------------+ +double CChart::PriceOnDropped(void) const + { +//--- check + if(m_chart_id==-1) + return(EMPTY_VALUE); +//--- result + return(ChartPriceOnDropped()); + } +//+------------------------------------------------------------------+ +//| Access function TimeOnDropped() | +//+------------------------------------------------------------------+ +datetime CChart::TimeOnDropped(void) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartTimeOnDropped()); + } +//+------------------------------------------------------------------+ +//| Access functions XOnDropped() | +//+------------------------------------------------------------------+ +int CChart::XOnDropped(void) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return(ChartXOnDropped()); + } +//+------------------------------------------------------------------+ +//| Access functions YOnDropped() | +//+------------------------------------------------------------------+ +int CChart::YOnDropped(void) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return(ChartYOnDropped()); + } +//+------------------------------------------------------------------+ +//| Adds indicator to chart | +//+------------------------------------------------------------------+ +bool CChart::IndicatorAdd(const int subwin,const int handle) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartIndicatorAdd(m_chart_id,subwin,handle)); + } +//+------------------------------------------------------------------+ +//| Deletes indicator from chart | +//+------------------------------------------------------------------+ +bool CChart::IndicatorDelete(const int subwin,const string name) const + { +//--- check + if(m_chart_id==-1) + return(false); +//--- result + return(ChartIndicatorDelete(m_chart_id,subwin,name)); + } +//+------------------------------------------------------------------+ +//| Gets number of indicators in chart subwindow | +//+------------------------------------------------------------------+ +int CChart::IndicatorsTotal(const int subwin) const + { +//--- check + if(m_chart_id==-1) + return(0); +//--- result + return(ChartIndicatorsTotal(m_chart_id,subwin)); + } +//+------------------------------------------------------------------+ +//| Gets short name of indicator | +//+------------------------------------------------------------------+ +string CChart::IndicatorName(const int subwin,const int index) const + { +//--- check + if(m_chart_id==-1) + return(""); +//--- result + return(ChartIndicatorName(m_chart_id,subwin,index)); + } +//+------------------------------------------------------------------+ +//| Writing parameters of chart to file | +//+------------------------------------------------------------------+ +bool CChart::Save(const int file_handle) + { + string work_str; + int work_int; +//--- check + if(file_handle==INVALID_HANDLE || m_chart_id==-1) + return(false); +//--- write start marker - 0xFFFFFFFFFFFFFFFF + if(FileWriteLong(file_handle,-1)!=sizeof(long)) + return(false); +//--- write chart type + if(FileWriteInteger(file_handle,Type(),INT_VALUE)!=INT_VALUE) + return(false); +//--- write chart symbol + work_str=Symbol(); + work_int=StringLen(work_str); + if(FileWriteInteger(file_handle,work_int,INT_VALUE)!=INT_VALUE) + return(false); + if(work_int!=0) if(FileWriteString(file_handle,work_str,work_int)!=work_int) + return(false); +//--- write period of chart + if(FileWriteInteger(file_handle,Period(),INT_VALUE)!=sizeof(int)) + return(false); +//--- write value of the "Mode" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_MODE),INT_VALUE)!=sizeof(int)) + return(false); +//--- write value of the "Foreground" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_FOREGROUND),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write value of the "Shift" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SHIFT),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write value of the "ShiftSize" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SHIFT),INT_VALUE)!=sizeof(int)) + return(false); +//--- write value of the "AutoScroll" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_AUTOSCROLL),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write value of the "Scale" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SCALE),INT_VALUE)!=sizeof(int)) + return(false); +//--- write value of the "ScaleFix" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SCALEFIX),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write value of the "ScaleFix_11" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SCALEFIX_11),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write value of the "FixedMax" property + if(FileWriteDouble(file_handle,ChartGetDouble(m_chart_id,CHART_FIXED_MAX))!=sizeof(double)) + return(false); +//--- write value of the "FixedMin" property + if(FileWriteDouble(file_handle,ChartGetDouble(m_chart_id,CHART_FIXED_MIN))!=sizeof(double)) + return(false); +//--- write the "ScalePPB" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SCALE_PT_PER_BAR),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write value of the "PointsPerBar" property + if(FileWriteDouble(file_handle,ChartGetDouble(m_chart_id,CHART_POINTS_PER_BAR))!=sizeof(double)) + return(false); +//--- write value of the "ShowOHLC" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SHOW_OHLC),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write value of the "ShowLineBid" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SHOW_BID_LINE),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write value of the "ShowLineAsk" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SHOW_ASK_LINE),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write value of the "ShowLastLine" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SHOW_LAST_LINE),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write value of the "ShowPeriodSep" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SHOW_PERIOD_SEP),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write value of the "ShowGrid" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SHOW_GRID),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- write value of the "ShowVolumes" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SHOW_VOLUMES),INT_VALUE)!=sizeof(int)) + return(false); +//--- write value of the "ShowObjectDescr" property + if(FileWriteInteger(file_handle,(int)ChartGetInteger(m_chart_id,CHART_SHOW_OBJECT_DESCR),CHAR_VALUE)!=sizeof(char)) + return(false); +//--- successful + return(true); + } +//+------------------------------------------------------------------+ +//| Reading parameters of chart from file | +//+------------------------------------------------------------------+ +bool CChart::Load(const int file_handle) + { + bool resutl=true; + string work_str; + int work_int; +//--- check + if(file_handle==INVALID_HANDLE || m_chart_id==-1) + return(false); +//--- read and checking start marker - 0xFFFFFFFFFFFFFFFF + if(FileReadLong(file_handle)!=-1) return(false); +//--- read and checking chart type + if(FileReadInteger(file_handle,INT_VALUE)!=Type()) return(false); +//--- read chart symbol + work_int=FileReadInteger(file_handle); + if(work_int!=0) work_str=FileReadString(file_handle,work_int); + else work_str=""; +//--- read chart period + work_int=FileReadInteger(file_handle); + SetSymbolPeriod(work_str,(ENUM_TIMEFRAMES)work_int); +//--- read value of the "Mode" property + if(!ChartSetInteger(m_chart_id,CHART_MODE,FileReadInteger(file_handle,INT_VALUE))) + return(false); +//--- read value of the "Foreground" property + if(!ChartSetInteger(m_chart_id,CHART_FOREGROUND,FileReadInteger(file_handle,CHAR_VALUE))) + return(false); +//--- read value of the "Shift" property + if(!ChartSetInteger(m_chart_id,CHART_SHIFT,FileReadInteger(file_handle,CHAR_VALUE))) + return(false); +//--- read value of the "ShiftSize" property + if(!ChartSetInteger(m_chart_id,CHART_SHIFT,FileReadInteger(file_handle,INT_VALUE))) + return(false); +//--- read value of the "AutoScroll" property + if(!ChartSetInteger(m_chart_id,CHART_AUTOSCROLL,FileReadInteger(file_handle,CHAR_VALUE))) + return(false); +//--- read value of the "Scale" property + if(!ChartSetInteger(m_chart_id,CHART_SCALE,FileReadInteger(file_handle,INT_VALUE))) + return(false); +//--- read value of the "ScaleFix" property + if(!ChartSetInteger(m_chart_id,CHART_SCALEFIX,FileReadInteger(file_handle,CHAR_VALUE))) + return(false); +//--- read value of the "ScaleFix_11" property + if(!ChartSetInteger(m_chart_id,CHART_SCALEFIX_11,FileReadInteger(file_handle,CHAR_VALUE))) + return(false); +//--- read value of the "FixedMax" property + if(!ChartSetDouble(m_chart_id,CHART_FIXED_MAX,FileReadDatetime(file_handle))) + return(false); +//--- read value of the "FixedMin" property + if(!ChartSetDouble(m_chart_id,CHART_FIXED_MIN,FileReadDatetime(file_handle))) + return(false); +//--- read value of the "ScalePPB" property + if(!ChartSetInteger(m_chart_id,CHART_SCALE_PT_PER_BAR,FileReadInteger(file_handle,CHAR_VALUE))) + return(false); +//--- read value of the "PointsPerBar" property + if(!ChartSetDouble(m_chart_id,CHART_POINTS_PER_BAR,FileReadDatetime(file_handle))) + return(false); +//--- read value of the "ShowOHLC" property + if(!ChartSetInteger(m_chart_id,CHART_SHOW_OHLC,FileReadInteger(file_handle,CHAR_VALUE))) + return(false); +//--- read value of the "ShowLineBid" property + if(!ChartSetInteger(m_chart_id,CHART_SHOW_BID_LINE,FileReadInteger(file_handle,CHAR_VALUE))) + return(false); +//--- read value of the "ShowLineAsk" property + if(!ChartSetInteger(m_chart_id,CHART_SHOW_ASK_LINE,FileReadInteger(file_handle,CHAR_VALUE))) + return(false); +//--- read value of the "ShowLastLine" property + if(!ChartSetInteger(m_chart_id,CHART_SHOW_LAST_LINE,FileReadInteger(file_handle,CHAR_VALUE))) + return(false); +//--- read value of the "ShowPeriodSep" property + if(!ChartSetInteger(m_chart_id,CHART_SHOW_PERIOD_SEP,FileReadInteger(file_handle,CHAR_VALUE))) + return(false); +//--- read value of the "ShowGrid" property + if(!ChartSetInteger(m_chart_id,CHART_SHOW_GRID,FileReadInteger(file_handle,CHAR_VALUE))) + return(false); +//--- read value of the "ShowVolumes" property + if(!ChartSetInteger(m_chart_id,CHART_SHOW_VOLUMES,FileReadInteger(file_handle,INT_VALUE))) + return(false); +//--- read value of the "ShowObjectDescr" property + if(!ChartSetInteger(m_chart_id,CHART_SHOW_OBJECT_DESCR,FileReadInteger(file_handle,CHAR_VALUE))) + return(false); +//--- successful + return(resutl); + } +//+------------------------------------------------------------------+