Add files via upload

This commit is contained in:
amirghadiri1987
2025-02-07 19:04:41 +03:30
committed by GitHub
parent df71b67cc0
commit b03fabf92b
13 changed files with 6717 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+205
View File
@@ -0,0 +1,205 @@
//+------------------------------------------------------------------+
//| ChartObjectPanel.mqh |
//| Copyright 2000-2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#include <ChartObjects\ChartObjectsTxtControls.mqh>
#include <Arrays\ArrayObj.mqh>
#include <Arrays\ArrayInt.mqh>
//+------------------------------------------------------------------+
//| 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<m_attachment.Total();i++)
{
chart_object=m_attachment.At(i);
chart_object.X_Distance(X+m_dX.At(i));
}
//---
return(CChartObjectButton::X_Distance(X));
}
//+------------------------------------------------------------------+
//| Method Y_Distance |
//+------------------------------------------------------------------+
bool CChartObjectPanel::Y_Distance(const int Y)
{
CChartObjectLabel *chart_object;
//---
for(int i=0;i<m_attachment.Total();i++)
{
chart_object=m_attachment.At(i);
chart_object.Y_Distance(Y+m_dY.At(i));
}
//---
return(CChartObjectButton::Y_Distance(Y));
}
//+------------------------------------------------------------------+
//| Method X_Size |
//+------------------------------------------------------------------+
int CChartObjectPanel::X_Size() const
{
int max_x=CChartObjectButton::X_Size()+X_Distance();
CChartObjectLabel *chart_object;
//---
if(m_expanded)
{
for(int i=0;i<m_attachment.Total();i++)
if((chart_object=m_attachment.At(i))!=NULL)
if(max_x<chart_object.X_Distance()+chart_object.X_Size())
max_x=chart_object.X_Distance()+chart_object.X_Size();
return(max_x-X_Distance()+2);
}
//---
return(CChartObjectButton::X_Size()+2);
}
//+------------------------------------------------------------------+
//| Method Y_Size |
//+------------------------------------------------------------------+
int CChartObjectPanel::Y_Size() const
{
int max_y=CChartObjectButton::Y_Size()+Y_Distance();
CChartObjectLabel *chart_object;
//---
if(m_expanded)
{
for(int i=0;i<m_attachment.Total();i++)
if((chart_object=m_attachment.At(i))!=NULL)
if(max_y<chart_object.Y_Distance()+chart_object.Y_Size())
max_y=chart_object.Y_Distance()+chart_object.Y_Size();
return(max_y-Y_Distance()+2);
}
//---
return(CChartObjectButton::Y_Size()+2);
}
//+------------------------------------------------------------------+
//| Method Timeframes |
//+------------------------------------------------------------------+
bool CChartObjectPanel::Timeframes(const int timeframes)
{
int i;
bool res=CChartObject::Timeframes(timeframes);
CChartObjectLabel *chart_object;
//---
if(m_expanded)
for(i=0;i<m_attachment.Total();i++)
{
chart_object=m_attachment.At(i);
res&=chart_object.Timeframes(timeframes);
}
//---
return(res);
}
//+------------------------------------------------------------------+
//| Method State |
//+------------------------------------------------------------------+
bool CChartObjectPanel::State(const bool state)
{
if(CChartObjectButton::State(state))
{
m_expanded=state;
return(true);
}
//---
return(false);
}
//+------------------------------------------------------------------+
//| Method CheckState |
//+------------------------------------------------------------------+
bool CChartObjectPanel::CheckState(void)
{
int i;
CChartObjectLabel *chart_object;
//---
if(m_expanded!=State())
{
if(m_expanded=State())
//--- make all objects visible
for(i=0;i<m_attachment.Total();i++)
{
chart_object=m_attachment.At(i);
chart_object.Timeframes(-1);
}
else
//--- make all objects invisible
for(i=0;i<m_attachment.Total();i++)
{
chart_object=m_attachment.At(i);
chart_object.Timeframes(0x100000);
}
return(true);
}
//---
return(false);
}
//+------------------------------------------------------------------+
+398
View File
@@ -0,0 +1,398 @@
//+------------------------------------------------------------------+
//| ChartObjectSubChart.mqh |
//| Copyright 2000-2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#include "ChartObject.mqh"
//+------------------------------------------------------------------+
//| Class CChartObjectSubChart. |
//| Purpose: Class of the "SubChart" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectSubChart : public CChartObject
{
public:
CChartObjectSubChart(void);
~CChartObjectSubChart(void);
//--- method of creating object
bool Create(long chart_id,const string name,const int window,const int X,const int Y,const int sizeX,const int sizeY);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_CHART); }
//--- methods of access to properties of the object
int X_Distance(void) const;
bool X_Distance(const int X) const;
int Y_Distance(void) const;
bool Y_Distance(const int Y) const;
ENUM_BASE_CORNER Corner(void) const;
bool Corner(const ENUM_BASE_CORNER corner) const;
int X_Size(void) const;
bool X_Size(const int size) const;
int Y_Size(void) const;
bool Y_Size(const int size) const;
string Symbol(void) const;
bool Symbol(const string symbol) const;
int Period(void) const;
bool Period(const int period) const;
int Scale(void) const;
bool Scale(const int scale) const;
bool DateScale(void) const;
bool DateScale(const bool scale) const;
bool PriceScale(void) const;
bool PriceScale(const bool scale) const;
//--- change of time/price coordinates is blocked
datetime Time(const int point) const { return(CChartObject::Time(point)); }
bool Time(const int point,const datetime time) const { return(false); }
double Price(const int point) const { return(CChartObject::Price(point)); }
bool Price(const int point,const double price) const { return(false); }
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectSubChart::CChartObjectSubChart(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectSubChart::~CChartObjectSubChart(void)
{
}
//+------------------------------------------------------------------+
//| Create object "SubChart" |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::Create(long chart_id,const string name,const int window,
const int X,const int Y,const int sizeX,const int sizeY)
{
if(!ObjectCreate(chart_id,name,OBJ_CHART,window,0,0,0))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
if(!X_Distance(X) || !Y_Distance(Y))
return(false);
if(!X_Size(sizeX) || !Y_Size(sizeY))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get the X-distance |
//+------------------------------------------------------------------+
int CChartObjectSubChart::X_Distance(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XDISTANCE));
}
//+------------------------------------------------------------------+
//| Set the X-distance |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::X_Distance(const int X) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_XDISTANCE,X));
}
//+------------------------------------------------------------------+
//| Get the Y-distance |
//+------------------------------------------------------------------+
int CChartObjectSubChart::Y_Distance(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YDISTANCE));
}
//+------------------------------------------------------------------+
//| Set the Y-distance |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::Y_Distance(const int Y) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_YDISTANCE,Y));
}
//+------------------------------------------------------------------+
//| Get base corner |
//+------------------------------------------------------------------+
ENUM_BASE_CORNER CChartObjectSubChart::Corner(void) const
{
//--- check
if(m_chart_id==-1)
return(WRONG_VALUE);
//--- result
return((ENUM_BASE_CORNER)ObjectGetInteger(m_chart_id,m_name,OBJPROP_CORNER));
}
//+------------------------------------------------------------------+
//| Set base corner |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::Corner(const ENUM_BASE_CORNER corner) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_CORNER,corner));
}
//+------------------------------------------------------------------+
//| Get the X-size |
//+------------------------------------------------------------------+
int CChartObjectSubChart::X_Size(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XSIZE));
}
//+------------------------------------------------------------------+
//| Set X-size |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::X_Size(const int size) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_XSIZE,size));
}
//+------------------------------------------------------------------+
//| Get the Y-size |
//+------------------------------------------------------------------+
int CChartObjectSubChart::Y_Size(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YSIZE));
}
//+------------------------------------------------------------------+
//| Set the Y-size |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::Y_Size(const int size) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_YSIZE,size));
}
//+------------------------------------------------------------------+
//| Get chart symbol |
//+------------------------------------------------------------------+
string CChartObjectSubChart::Symbol(void) const
{
//--- check
if(m_chart_id==-1)
return("");
//--- result
return(ObjectGetString(m_chart_id,m_name,OBJPROP_SYMBOL));
}
//+------------------------------------------------------------------+
//| Set chart symbol |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::Symbol(const string symbol) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetString(m_chart_id,m_name,OBJPROP_SYMBOL,symbol));
}
//+------------------------------------------------------------------+
//| Get chart period |
//+------------------------------------------------------------------+
int CChartObjectSubChart::Period(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_PERIOD));
}
//+------------------------------------------------------------------+
//| Set chart period |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::Period(const int period) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_PERIOD,period));
}
//+------------------------------------------------------------------+
//| Get chart scale |
//+------------------------------------------------------------------+
int CChartObjectSubChart::Scale(void) const
{
//--- check
if(m_chart_id==-1)
return(-1);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_CHART_SCALE));
}
//+------------------------------------------------------------------+
//| Set chart scale |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::Scale(const int scale) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_CHART_SCALE,scale));
}
//+------------------------------------------------------------------+
//| Get the "time scale" flag |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::DateScale(void) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_DATE_SCALE));
}
//+------------------------------------------------------------------+
//| Set the "time scale" flag |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::DateScale(const bool scale) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_DATE_SCALE,scale));
}
//+------------------------------------------------------------------+
//| Get the "price scale" flag |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::PriceScale(void) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_PRICE_SCALE));
}
//+------------------------------------------------------------------+
//| Set the "price scale" flag |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::PriceScale(const bool scale) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_PRICE_SCALE,scale));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::Save(const int file_handle)
{
int len;
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObject::Save(file_handle))
return(false);
//--- write value of the "X-distance" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XDISTANCE),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "Y-distance" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YDISTANCE),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "corner" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_CORNER),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "X-size" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XSIZE),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "Y-size" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YSIZE),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "symbol" property
str=ObjectGetString(m_chart_id,m_name,OBJPROP_SYMBOL);
len=StringLen(str);
if(FileWriteInteger(file_handle,len,INT_VALUE)!=INT_VALUE)
return(false);
if(len!=0 && FileWriteString(file_handle,str,len)!=len)
return(false);
//--- write value of the "period" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_PERIOD),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "scale" property
if(FileWriteDouble(file_handle,ObjectGetDouble(m_chart_id,m_name,OBJPROP_SCALE))!=sizeof(double))
return(false);
//--- write value of the "time scale" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_DATE_SCALE),CHAR_VALUE)!=sizeof(char))
return(false);
//--- write value of the "price scale" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_PRICE_SCALE),CHAR_VALUE)!=sizeof(char))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading parameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectSubChart::Load(const int file_handle)
{
int len;
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObject::Load(file_handle))
return(false);
//--- read value of the "X-distance" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_XDISTANCE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "Y-distance" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_YDISTANCE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "corner" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_CORNER,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "X-size" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_XSIZE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "Y-size" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_YSIZE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "symbol" property
len=FileReadInteger(file_handle,INT_VALUE);
str=(len!=0) ? FileReadString(file_handle,len) : "";
if(!ObjectSetString(m_chart_id,m_name,OBJPROP_SYMBOL,str))
return(false);
//--- read value of the "period" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_PERIOD,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "scale" property
if(!ObjectSetDouble(m_chart_id,m_name,OBJPROP_SCALE,FileReadDatetime(file_handle)))
return(false);
//--- read value of the "time scale" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_DATE_SCALE,FileReadInteger(file_handle,CHAR_VALUE)))
return(false);
//--- read value of the "price scale" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_PRICE_SCALE,FileReadInteger(file_handle,CHAR_VALUE)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
+479
View File
@@ -0,0 +1,479 @@
//+------------------------------------------------------------------+
//| ChartObjectsArrows.mqh |
//| Copyright 2000-2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//| All arrows. |
//+------------------------------------------------------------------+
#include "ChartObject.mqh"
//+------------------------------------------------------------------+
//| Class CChartObjectArrow. |
//| Purpose: Class of the "Arrow" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectArrow : public CChartObject
{
public:
CChartObjectArrow(void);
~CChartObjectArrow(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const datetime time,const double price,const char code);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_ARROW); }
//--- methods of access to properties of the object
char ArrowCode(void) const;
virtual bool ArrowCode(const char code) const;
ENUM_ARROW_ANCHOR Anchor(void) const;
virtual bool Anchor(const ENUM_ARROW_ANCHOR anchor) const;
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectArrow::CChartObjectArrow(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectArrow::~CChartObjectArrow(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Arrow" |
//+------------------------------------------------------------------+
bool CChartObjectArrow::Create(long chart_id,const string name,const int window,const datetime time,const double price,const char code)
{
if(!ObjectCreate(chart_id,name,OBJ_ARROW,window,time,price))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
if(!ArrowCode(code))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get code of "arrow" symbol |
//+------------------------------------------------------------------+
char CChartObjectArrow::ArrowCode(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((char)ObjectGetInteger(m_chart_id,m_name,OBJPROP_ARROWCODE));
}
//+------------------------------------------------------------------+
//| Set code of "arrow" symbol |
//+------------------------------------------------------------------+
bool CChartObjectArrow::ArrowCode(const char code) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_ARROWCODE,code));
}
//+------------------------------------------------------------------+
//| Get anchor type |
//+------------------------------------------------------------------+
ENUM_ARROW_ANCHOR CChartObjectArrow::Anchor(void) const
{
//--- result
return((ENUM_ARROW_ANCHOR)ObjectGetInteger(m_chart_id,m_name,OBJPROP_ANCHOR));
}
//+------------------------------------------------------------------+
//| Set anchor type |
//+------------------------------------------------------------------+
bool CChartObjectArrow::Anchor(const ENUM_ARROW_ANCHOR anchor) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_ANCHOR,anchor));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectArrow::Save(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- writing
if(!CObject::Save(file_handle))
return(false);
//--- write code of "arrow" symbol
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_ARROWCODE),CHAR_VALUE)!=sizeof(char))
return(false);
//--- write anchor type
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_ANCHOR),INT_VALUE)!=sizeof(int))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading parameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectArrow::Load(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- reading
if(!CObject::Load(file_handle))
return(false);
//--- read code of "arrow" symbol
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_ARROWCODE,FileReadInteger(file_handle,CHAR_VALUE)))
return(false);
//--- read anchor type
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_ANCHOR,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectArrowThumbUp. |
//| Purpose: Class of the "Thumbs Up" object of chart. |
//| Derives from class CChartObjectArrow. |
//+------------------------------------------------------------------+
class CChartObjectArrowThumbUp : public CChartObjectArrow
{
public:
CChartObjectArrowThumbUp(void);
~CChartObjectArrowThumbUp(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const datetime time,const double price);
//--- method of identifying the object
virtual int Type(void) const override { return(OBJ_ARROW_THUMB_UP); }
//--- change of arrow code is blocked
virtual bool ArrowCode(const char code) const override { return(false); }
char ArrowCode(void) const { return(CChartObjectArrow::ArrowCode()); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectArrowThumbUp::CChartObjectArrowThumbUp(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectArrowThumbUp::~CChartObjectArrowThumbUp(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Thumbs Up" |
//+------------------------------------------------------------------+
bool CChartObjectArrowThumbUp::Create(long chart_id,const string name,const int window,const datetime time,const double price)
{
if(!ObjectCreate(chart_id,name,OBJ_ARROW_THUMB_UP,window,time,price))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectArrowThumbDown. |
//| Purpose: Class of the "Thumbs Down" object of chart. |
//| Derives from class CChartObjectArrow. |
//+------------------------------------------------------------------+
class CChartObjectArrowThumbDown : public CChartObjectArrow
{
public:
CChartObjectArrowThumbDown(void);
~CChartObjectArrowThumbDown(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const datetime time,const double price);
//--- method of identifying the object
virtual int Type(void) const override { return(OBJ_ARROW_THUMB_DOWN); }
//--- change of arrow code is blocked
virtual bool ArrowCode(const char code) const override { return(false); }
char ArrowCode(void) const { return(CChartObjectArrow::ArrowCode()); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectArrowThumbDown::CChartObjectArrowThumbDown(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectArrowThumbDown::~CChartObjectArrowThumbDown(void)
{
}
//+------------------------------------------------------------------+
//| Create object "ThumbsDown" |
//+------------------------------------------------------------------+
bool CChartObjectArrowThumbDown::Create(long chart_id,const string name,const int window,const datetime time,const double price)
{
if(!ObjectCreate(chart_id,name,OBJ_ARROW_THUMB_DOWN,window,time,price))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectArrowUp. |
//| Purpose: Class of the "Arrow Up" object of chart. |
//| Derives from class CChartObjectArrow. |
//+------------------------------------------------------------------+
class CChartObjectArrowUp : public CChartObjectArrow
{
public:
CChartObjectArrowUp(void);
~CChartObjectArrowUp(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const datetime time,const double price);
//--- method of identifying the object
virtual int Type(void) const override { return(OBJ_ARROW_UP); }
//--- change of arrow code is blocked
virtual bool ArrowCode(const char code) const override { return(false); }
char ArrowCode(void) const { return(CChartObjectArrow::ArrowCode()); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectArrowUp::CChartObjectArrowUp(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectArrowUp::~CChartObjectArrowUp(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Arrow Up" |
//+------------------------------------------------------------------+
bool CChartObjectArrowUp::Create(long chart_id,const string name,const int window,const datetime time,const double price)
{
if(!ObjectCreate(chart_id,name,OBJ_ARROW_UP,window,time,price))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectArrowDown. |
//| Purpose: Class of the "Arrow Down" object of chart. |
//| Derives from class CChartObjectArrow. |
//+------------------------------------------------------------------+
class CChartObjectArrowDown : public CChartObjectArrow
{
public:
CChartObjectArrowDown(void);
~CChartObjectArrowDown(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const datetime time,const double price);
//--- method of identifying the object
virtual int Type(void) const override { return(OBJ_ARROW_DOWN); }
//--- change of arrow code is blocked
virtual bool ArrowCode(const char code) const override { return(false); }
char ArrowCode(void) const { return(CChartObjectArrow::ArrowCode()); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectArrowDown::CChartObjectArrowDown(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectArrowDown::~CChartObjectArrowDown(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Arrow Down" |
//+------------------------------------------------------------------+
bool CChartObjectArrowDown::Create(long chart_id,const string name,const int window,const datetime time,const double price)
{
if(!ObjectCreate(chart_id,name,OBJ_ARROW_DOWN,window,time,price))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectArrowStop. |
//| Purpose: Class of the "Stop Sign" object of chart. |
//| Derives from class CChartObjectArrow. |
//+------------------------------------------------------------------+
class CChartObjectArrowStop : public CChartObjectArrow
{
public:
CChartObjectArrowStop(void);
~CChartObjectArrowStop(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const datetime time,const double price);
//--- method of identifying the object
virtual int Type(void) const override { return(OBJ_ARROW_STOP); }
//--- change of arrow code is blocked
virtual bool ArrowCode(const char code) const override { return(false); }
char ArrowCode(void) const { return(CChartObjectArrow::ArrowCode()); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectArrowStop::CChartObjectArrowStop(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectArrowStop::~CChartObjectArrowStop(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Stop Sign" |
//+------------------------------------------------------------------+
bool CChartObjectArrowStop::Create(long chart_id,const string name,const int window,const datetime time,const double price)
{
if(!ObjectCreate(chart_id,name,OBJ_ARROW_STOP,window,time,price))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectArrowCheck. |
//| Purpose: Class of the "Check Sign" object of chart. |
//| Derives from class CChartObjectArrow. |
//+------------------------------------------------------------------+
class CChartObjectArrowCheck : public CChartObjectArrow
{
public:
CChartObjectArrowCheck(void);
~CChartObjectArrowCheck(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const datetime time,const double price);
//--- method of identifying the object
virtual int Type(void) const override { return(OBJ_ARROW_CHECK); }
//--- change of arrow code is blocked
virtual bool ArrowCode(const char code) const override { return(false); }
char ArrowCode(void) const { return(CChartObjectArrow::ArrowCode()); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectArrowCheck::CChartObjectArrowCheck(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectArrowCheck::~CChartObjectArrowCheck(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Check Sign" |
//+------------------------------------------------------------------+
bool CChartObjectArrowCheck::Create(long chart_id,const string name,const int window,const datetime time,const double price)
{
if(!ObjectCreate(chart_id,name,OBJ_ARROW_CHECK,window,time,price))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectArrowLeftPrice. |
//| Purpose: Class of the "Left Price Label" object of chart. |
//| Derives from class CChartObjectArrow. |
//+------------------------------------------------------------------+
class CChartObjectArrowLeftPrice : public CChartObjectArrow
{
public:
CChartObjectArrowLeftPrice(void);
~CChartObjectArrowLeftPrice(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const datetime time,const double price);
//--- method of identifying the object
virtual int Type(void) const override { return(OBJ_ARROW_LEFT_PRICE); }
//--- change of arrow code and anchor point is blocked
virtual bool ArrowCode(const char code) const override { return(false); }
char ArrowCode(void) const { return(CChartObjectArrow::ArrowCode()); }
virtual bool Anchor(const ENUM_ARROW_ANCHOR anchor) const override { return(false); }
ENUM_ARROW_ANCHOR Anchor(void) const { return(CChartObjectArrow::Anchor()); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectArrowLeftPrice::CChartObjectArrowLeftPrice(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectArrowLeftPrice::~CChartObjectArrowLeftPrice(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Left Price Label" |
//+------------------------------------------------------------------+
bool CChartObjectArrowLeftPrice::Create(long chart_id,const string name,const int window,const datetime time,const double price)
{
if(!ObjectCreate(chart_id,name,OBJ_ARROW_LEFT_PRICE,window,time,price))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectArrowRightPrice. |
//| Purpose: Class of the "Right Price Label" object of chart. |
//| Derives from class CChartObjectArrow. |
//+------------------------------------------------------------------+
class CChartObjectArrowRightPrice : public CChartObjectArrow
{
public:
CChartObjectArrowRightPrice(void);
~CChartObjectArrowRightPrice(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const datetime time,const double price);
//--- method of identifying the object
virtual int Type(void) const override { return(OBJ_ARROW_RIGHT_PRICE); }
//--- change of arrow code and anchor point is blocked
virtual bool ArrowCode(const char code) const override { return(false); }
char ArrowCode(void) const { return(CChartObjectArrow::ArrowCode()); }
virtual bool Anchor(const ENUM_ARROW_ANCHOR anchor) const override { return(false); }
ENUM_ARROW_ANCHOR Anchor(void) const { return(CChartObjectArrow::Anchor()); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectArrowRightPrice::CChartObjectArrowRightPrice(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectArrowRightPrice::~CChartObjectArrowRightPrice(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Right Price Label" |
//+------------------------------------------------------------------+
bool CChartObjectArrowRightPrice::Create(long chart_id,const string name,const int window,const datetime time,const double price)
{
if(!ObjectCreate(chart_id,name,OBJ_ARROW_RIGHT_PRICE,window,time,price))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
+512
View File
@@ -0,0 +1,512 @@
//+------------------------------------------------------------------+
//| ChartObjectsBmpControls.mqh |
//| Copyright 2000-2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//| All objects with "bmp" pictures. |
//+------------------------------------------------------------------+
#include "ChartObject.mqh"
//+------------------------------------------------------------------+
//| Class CChartObjectBitmap. |
//| Purpose: Class of the "Bitmap" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectBitmap : public CChartObject
{
public:
CChartObjectBitmap(void);
~CChartObjectBitmap(void);
//--- methods of access to properties of the object
string BmpFile(void) const;
bool BmpFile(const string name) const;
int X_Offset(void) const;
bool X_Offset(const int X) const;
int Y_Offset(void) const;
bool Y_Offset(const int Y) const;
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const datetime time,const double price);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_BITMAP); }
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectBitmap::CChartObjectBitmap(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectBitmap::~CChartObjectBitmap(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Bitmapp" |
//+------------------------------------------------------------------+
bool CChartObjectBitmap::Create(long chart_id,const string name,const int window,const datetime time,const double price)
{
if(!ObjectCreate(chart_id,name,OBJ_BITMAP,window,time,price))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get name of bmp-file |
//+------------------------------------------------------------------+
string CChartObjectBitmap::BmpFile(void) const
{
//--- check
if(m_chart_id==-1)
return("");
//--- result
return(ObjectGetString(m_chart_id,m_name,OBJPROP_BMPFILE));
}
//+------------------------------------------------------------------+
//| Set name of bmp-file |
//+------------------------------------------------------------------+
bool CChartObjectBitmap::BmpFile(const string name) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetString(m_chart_id,m_name,OBJPROP_BMPFILE,name));
}
//+------------------------------------------------------------------+
//| Get the XOffset property |
//+------------------------------------------------------------------+
int CChartObjectBitmap::X_Offset(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XOFFSET));
}
//+------------------------------------------------------------------+
//| Set the XOffset property |
//+------------------------------------------------------------------+
bool CChartObjectBitmap::X_Offset(const int X) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_XOFFSET,X));
}
//+------------------------------------------------------------------+
//| Get the YOffset property |
//+------------------------------------------------------------------+
int CChartObjectBitmap::Y_Offset(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YOFFSET));
}
//+------------------------------------------------------------------+
//| Set the YOffset property |
//+------------------------------------------------------------------+
bool CChartObjectBitmap::Y_Offset(const int Y) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_YOFFSET,Y));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectBitmap::Save(const int file_handle)
{
int len;
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObject::Save(file_handle))
return(false);
//--- write value of the "name of bmp-file" property
str=ObjectGetString(m_chart_id,m_name,OBJPROP_BMPFILE);
len=StringLen(str);
if(FileWriteInteger(file_handle,len,INT_VALUE)!=INT_VALUE)
return(false);
if(len!=0 && FileWriteString(file_handle,str,len)!=len)
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading parameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectBitmap::Load(const int file_handle)
{
int len;
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObject::Load(file_handle))
return(false);
//--- read value of the "name of bmp-file" property
len=FileReadInteger(file_handle,INT_VALUE);
str=(len!=0) ? FileReadString(file_handle,len) : "";
if(!ObjectSetString(m_chart_id,m_name,OBJPROP_BMPFILE,str))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectBmpLabel. |
//| Purpose: Class of the "Bitmap label" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectBmpLabel : public CChartObject
{
public:
CChartObjectBmpLabel(void);
~CChartObjectBmpLabel(void);
//--- methods of access to properties of the object
int X_Distance(void) const;
bool X_Distance(const int X) const;
int Y_Distance(void) const;
bool Y_Distance(const int Y) const;
int X_Size(void) const;
int Y_Size(void) const;
ENUM_BASE_CORNER Corner(void) const;
bool Corner(const ENUM_BASE_CORNER corner) const;
string BmpFileOn(void) const;
bool BmpFileOn(const string name) const;
string BmpFileOff(void) const;
bool BmpFileOff(const string name) const;
bool State(void) const;
bool State(const bool state) const;
int X_Offset(void) const;
bool X_Offset(const int X) const;
int Y_Offset(void) const;
bool Y_Offset(const int Y) const;
//--- change of time/price coordinates is blocked
bool Time(const datetime time) const { return(false); }
bool Price(const double price) const { return(false); }
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const int X,const int Y);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_BITMAP_LABEL); }
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectBmpLabel::CChartObjectBmpLabel(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectBmpLabel::~CChartObjectBmpLabel(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Bitmap label" |
//+------------------------------------------------------------------+
bool CChartObjectBmpLabel::Create(long chart_id,const string name,const int window,const int X,const int Y)
{
if(!ObjectCreate(chart_id,name,OBJ_BITMAP_LABEL,window,0,0.0))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
if(!X_Distance(X) || !Y_Distance(Y))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get the X-distance property |
//+------------------------------------------------------------------+
int CChartObjectBmpLabel::X_Distance(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XDISTANCE));
}
//+------------------------------------------------------------------+
//| Set the X-distance property |
//+------------------------------------------------------------------+
bool CChartObjectBmpLabel::X_Distance(const int X) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_XDISTANCE,X));
}
//+------------------------------------------------------------------+
//| Get the Y-distance property |
//+------------------------------------------------------------------+
int CChartObjectBmpLabel::Y_Distance(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YDISTANCE));
}
//+------------------------------------------------------------------+
//| Set the Y-distance property |
//+------------------------------------------------------------------+
bool CChartObjectBmpLabel::Y_Distance(const int Y) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_YDISTANCE,Y));
}
//+------------------------------------------------------------------+
//| Get the X-size |
//+------------------------------------------------------------------+
int CChartObjectBmpLabel::X_Size(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XSIZE));
}
//+------------------------------------------------------------------+
//| Get the Y-size |
//+------------------------------------------------------------------+
int CChartObjectBmpLabel::Y_Size(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YSIZE));
}
//+------------------------------------------------------------------+
//| Get the Corner property |
//+------------------------------------------------------------------+
ENUM_BASE_CORNER CChartObjectBmpLabel::Corner(void) const
{
//--- check
if(m_chart_id==-1)
return(WRONG_VALUE);
//--- result
return((ENUM_BASE_CORNER)ObjectGetInteger(m_chart_id,m_name,OBJPROP_CORNER));
}
//+------------------------------------------------------------------+
//| Set the Corner property |
//+------------------------------------------------------------------+
bool CChartObjectBmpLabel::Corner(const ENUM_BASE_CORNER corner) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_CORNER,corner));
}
//+------------------------------------------------------------------+
//| Get filename of the "bmp-ON" property |
//+------------------------------------------------------------------+
string CChartObjectBmpLabel::BmpFileOn(void) const
{
//--- check
if(m_chart_id==-1)
return("");
//--- result
return(ObjectGetString(m_chart_id,m_name,OBJPROP_BMPFILE,0));
}
//+------------------------------------------------------------------+
//| Set filename for the "bmp-ON" property |
//+------------------------------------------------------------------+
bool CChartObjectBmpLabel::BmpFileOn(const string name) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetString(m_chart_id,m_name,OBJPROP_BMPFILE,0,name));
}
//+------------------------------------------------------------------+
//| Get filename of the "bmp-OFF" property |
//+------------------------------------------------------------------+
string CChartObjectBmpLabel::BmpFileOff(void) const
{
//--- check
if(m_chart_id==-1)
return("");
//--- result
return(ObjectGetString(m_chart_id,m_name,OBJPROP_BMPFILE,1));
}
//+------------------------------------------------------------------+
//| Set filename for the "bmp-OFF" property |
//+------------------------------------------------------------------+
bool CChartObjectBmpLabel::BmpFileOff(const string name) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetString(m_chart_id,m_name,OBJPROP_BMPFILE,1,name));
}
//+------------------------------------------------------------------+
//| Get the State property |
//+------------------------------------------------------------------+
bool CChartObjectBmpLabel::State(void) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_STATE));
}
//+------------------------------------------------------------------+
//| Set the State property |
//+------------------------------------------------------------------+
bool CChartObjectBmpLabel::State(const bool state) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_STATE,state));
}
//+------------------------------------------------------------------+
//| Get the XOffset property |
//+------------------------------------------------------------------+
int CChartObjectBmpLabel::X_Offset(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XOFFSET));
}
//+------------------------------------------------------------------+
//| Set the XOffset property |
//+------------------------------------------------------------------+
bool CChartObjectBmpLabel::X_Offset(const int X) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_XOFFSET,X));
}
//+------------------------------------------------------------------+
//| Get the YOffset property |
//+------------------------------------------------------------------+
int CChartObjectBmpLabel::Y_Offset(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YOFFSET));
}
//+------------------------------------------------------------------+
//| Set the YOffset property |
//+------------------------------------------------------------------+
bool CChartObjectBmpLabel::Y_Offset(const int Y) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_YOFFSET,Y));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectBmpLabel::Save(const int file_handle)
{
int len;
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObject::Save(file_handle))
return(false);
//--- write value of the "X-distance" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XDISTANCE),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "Y-distance" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YDISTANCE),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "Corner" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_CORNER),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "filename bmp-ON" property
str=ObjectGetString(m_chart_id,m_name,OBJPROP_BMPFILE,0);
len=StringLen(str);
if(FileWriteInteger(file_handle,len,INT_VALUE)!=INT_VALUE)
return(false);
if(len!=0 && FileWriteString(file_handle,str,len)!=len)
return(false);
//--- write value of the "filename bmp-OFF" property
str=ObjectGetString(m_chart_id,m_name,OBJPROP_BMPFILE,1);
len=StringLen(str);
if(FileWriteInteger(file_handle,len,INT_VALUE)!=INT_VALUE)
return(false);
if(len!=0 && FileWriteString(file_handle,str,len)!=len)
return(false);
//--- write state
if(FileWriteLong(file_handle,ObjectGetInteger(m_chart_id,m_name,OBJPROP_STATE))!=sizeof(long))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading object parameters from file |
//+------------------------------------------------------------------+
bool CChartObjectBmpLabel::Load(const int file_handle)
{
int len;
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObject::Load(file_handle))
return(false);
//--- read value of the "X-distance" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_XDISTANCE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "Y-distance" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_YDISTANCE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of "Corner" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_CORNER,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "filename bmp-ON" property
len=FileReadInteger(file_handle,INT_VALUE);
str=(len!=0) ? FileReadString(file_handle,len) : "";
if(!ObjectSetString(m_chart_id,m_name,OBJPROP_BMPFILE,0,str))
return(false);
//--- read value of the "filename bmp-OFF" property
len=FileReadInteger(file_handle,INT_VALUE);
str=(len!=0) ? FileReadString(file_handle,len) : "";
if(!ObjectSetString(m_chart_id,m_name,OBJPROP_BMPFILE,1,str))
return(false);
//--- read state
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_STATE,FileReadLong(file_handle)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
+246
View File
@@ -0,0 +1,246 @@
//+------------------------------------------------------------------+
//| ChartObjectsChannels.mqh |
//| Copyright 2000-2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//| All channels. |
//+------------------------------------------------------------------+
#include "ChartObjectsLines.mqh"
//+------------------------------------------------------------------+
//| Class CChartObjectChannel. |
//| Purpose: Class of the "Equidistant channel" object of chart. |
//| Derives from class CChartObjectTrend. |
//+------------------------------------------------------------------+
class CChartObjectChannel : public CChartObjectTrend
{
public:
CChartObjectChannel(void);
~CChartObjectChannel(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_CHANNEL); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectChannel::CChartObjectChannel(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectChannel::~CChartObjectChannel(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Equidistant channel" |
//+------------------------------------------------------------------+
bool CChartObjectChannel::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3)
{
if(!ObjectCreate(chart_id,name,OBJ_CHANNEL,window,time1,price1,time2,price2,time3,price3))
return(false);
if(!Attach(chart_id,name,window,3))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectStdDevChannel. |
//| Purpose: Class of the "Standrad deviation channel" |
//| object of chart. |
//| Derives from class CChartObjectTrend. |
//+------------------------------------------------------------------+
class CChartObjectStdDevChannel : public CChartObjectTrend
{
public:
CChartObjectStdDevChannel(void);
~CChartObjectStdDevChannel(void);
//--- methods of access to properties of the object
double Deviations(void) const;
bool Deviations(const double deviation) const;
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const datetime time2,const double deviation);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_STDDEVCHANNEL); }
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectStdDevChannel::CChartObjectStdDevChannel(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectStdDevChannel::~CChartObjectStdDevChannel(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Standard deviation channel" |
//+------------------------------------------------------------------+
bool CChartObjectStdDevChannel::Create(long chart_id,const string name,const int window,
const datetime time1,const datetime time2,const double deviation)
{
if(!ObjectCreate(chart_id,name,OBJ_STDDEVCHANNEL,window,time1,0.0,time2,0.0))
return(false);
if(!Attach(chart_id,name,window,2))
return(false);
if(!Deviations(deviation))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get value of the "Deviations" property |
//+------------------------------------------------------------------+
double CChartObjectStdDevChannel::Deviations(void) const
{
//--- check
if(m_chart_id==-1)
return(EMPTY_VALUE);
//--- result
return(ObjectGetDouble(m_chart_id,m_name,OBJPROP_DEVIATION));
}
//+------------------------------------------------------------------+
//| Set value for the "Deviations" property |
//+------------------------------------------------------------------+
bool CChartObjectStdDevChannel::Deviations(const double deviation) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetDouble(m_chart_id,m_name,OBJPROP_DEVIATION,deviation));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectStdDevChannel::Save(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObjectTrend::Save(file_handle))
return(false);
//--- write value of the "Deviations" property
if(FileWriteDouble(file_handle,ObjectGetDouble(m_chart_id,m_name,OBJPROP_DEVIATION))!=sizeof(double))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading parameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectStdDevChannel::Load(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObjectTrend::Load(file_handle))
return(false);
//--- read value of the "Deviations" property
if(!ObjectSetDouble(m_chart_id,m_name,OBJPROP_DEVIATION,FileReadDouble(file_handle)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectRegression. |
//| Purpose: Class of the "Regression channel" object of chart. |
//| Derives from class CChartObjectTrend. |
//+------------------------------------------------------------------+
class CChartObjectRegression : public CChartObjectTrend
{
public:
CChartObjectRegression(void);
~CChartObjectRegression(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const datetime time2);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_REGRESSION); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectRegression::CChartObjectRegression(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectRegression::~CChartObjectRegression(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Regression channel" |
//+------------------------------------------------------------------+
bool CChartObjectRegression::Create(long chart_id,const string name,const int window,
const datetime time1,const datetime time2)
{
if(!ObjectCreate(chart_id,name,OBJ_REGRESSION,window,time1,0.0,time2,0.0))
return(false);
if(!Attach(chart_id,name,window,2))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectPitchfork. |
//| Purpose: Class of the "Andrews pitchfork" object of chart |
//| Derives from class CChartObjectTrend. |
//+------------------------------------------------------------------+
class CChartObjectPitchfork : public CChartObjectTrend
{
public:
CChartObjectPitchfork(void);
~CChartObjectPitchfork(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_CHANNEL); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectPitchfork::CChartObjectPitchfork(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectPitchfork::~CChartObjectPitchfork(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Andrews pitchfork" |
//+------------------------------------------------------------------+
bool CChartObjectPitchfork::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3)
{
if(!ObjectCreate(chart_id,name,OBJ_PITCHFORK,window,time1,price1,time2,price2,time3,price3))
return(false);
if(!Attach(chart_id,name,window,3))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
+201
View File
@@ -0,0 +1,201 @@
//+------------------------------------------------------------------+
//| ChartObjectsElliott.mqh |
//| Copyright 2000-2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//| All Elliott tools. |
//+------------------------------------------------------------------+
#include "ChartObject.mqh"
//+------------------------------------------------------------------+
//| Class CChartObjectElliottWave3. |
//| Purpose: Class of the "ElliottCorrectiveWave" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectElliottWave3 : public CChartObject
{
public:
CChartObjectElliottWave3(void);
~CChartObjectElliottWave3(void);
//--- methods of access to properties of the object
ENUM_ELLIOT_WAVE_DEGREE Degree(void) const;
bool Degree(const ENUM_ELLIOT_WAVE_DEGREE degree) const;
bool Lines(void) const;
bool Lines(const bool lines) const;
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_ELLIOTWAVE3); }
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectElliottWave3::CChartObjectElliottWave3(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectElliottWave3::~CChartObjectElliottWave3(void)
{
}
//+------------------------------------------------------------------+
//| Create object "ElliottCorrectiveWave" |
//+------------------------------------------------------------------+
bool CChartObjectElliottWave3::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3)
{
if(!ObjectCreate(chart_id,name,OBJ_ELLIOTWAVE3,window,time1,price1,time2,price2,time3,price3))
return(false);
if(!Attach(chart_id,name,window,3))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get value of the "Degree" property |
//+------------------------------------------------------------------+
ENUM_ELLIOT_WAVE_DEGREE CChartObjectElliottWave3::Degree(void) const
{
//--- check
if(m_chart_id==-1)
return(WRONG_VALUE);
//--- result
return((ENUM_ELLIOT_WAVE_DEGREE)ObjectGetInteger(m_chart_id,m_name,OBJPROP_DEGREE));
}
//+------------------------------------------------------------------+
//| Set value for the "Degree" property |
//+------------------------------------------------------------------+
bool CChartObjectElliottWave3::Degree(const ENUM_ELLIOT_WAVE_DEGREE degree) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_DEGREE,degree));
}
//+------------------------------------------------------------------+
//| Get value of the "Lines" property |
//+------------------------------------------------------------------+
bool CChartObjectElliottWave3::Lines(void) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_DRAWLINES));
}
//+------------------------------------------------------------------+
//| Set value for the "Lines" property |
//+------------------------------------------------------------------+
bool CChartObjectElliottWave3::Lines(const bool lines) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_DRAWLINES,lines));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectElliottWave3::Save(const int file_handle)
{
bool result;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
result=CChartObject::Save(file_handle);
if(result)
{
//--- write value of the "Degree" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_DEGREE),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "Lines" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_DRAWLINES),INT_VALUE)!=sizeof(int))
return(false);
}
//--- result
return(result);
}
//+------------------------------------------------------------------+
//| Reading parameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectElliottWave3::Load(const int file_handle)
{
bool result;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
result=CChartObject::Load(file_handle);
if(result)
{
//--- read value of the "Degree" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_DEGREE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "Lines" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_DRAWLINES,FileReadInteger(file_handle,INT_VALUE)))
return(false);
}
//--- result
return(result);
}
//+------------------------------------------------------------------+
//| Class CChartObjectElliottWave5. |
//| Purpose: Class of the "ElliottMotiveWave" object of chart. |
//| Derives from class CChartObjectElliottWave3. |
//+------------------------------------------------------------------+
class CChartObjectElliottWave5 : public CChartObjectElliottWave3
{
public:
CChartObjectElliottWave5(void);
~CChartObjectElliottWave5(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3,
const datetime time4,const double price4,
const datetime time5,const double price5);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_ELLIOTWAVE5); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectElliottWave5::CChartObjectElliottWave5(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectElliottWave5::~CChartObjectElliottWave5(void)
{
}
//+------------------------------------------------------------------+
//| Create object "ElliottMotiveWave" |
//+------------------------------------------------------------------+
bool CChartObjectElliottWave5::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3,
const datetime time4,const double price4,
const datetime time5,const double price5)
{
if(!ObjectCreate(chart_id,name,OBJ_ELLIOTWAVE5,window,time1,price1,time2,price2,time3,price3,time4,price4,time5,price5))
return(false);
if(!Attach(chart_id,name,window,5))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
+365
View File
@@ -0,0 +1,365 @@
//+------------------------------------------------------------------+
//| ChartObjectsFibo.mqh |
//| Copyright 2000-2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//| All Fibonacci tools. |
//+------------------------------------------------------------------+
#include "ChartObjectsLines.mqh"
//+------------------------------------------------------------------+
//| Class CChartObjectFibo. |
//| Purpose: Class of the "Fibonacci Lines" object. |
//| Derives from class CChartObjectTrend. |
//+------------------------------------------------------------------+
class CChartObjectFibo : public CChartObjectTrend
{
public:
CChartObjectFibo(void);
~CChartObjectFibo(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_FIBO); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectFibo::CChartObjectFibo(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectFibo::~CChartObjectFibo(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Fibonacci Lines" |
//+------------------------------------------------------------------+
bool CChartObjectFibo::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2)
{
if(!ObjectCreate(chart_id,name,OBJ_FIBO,window,time1,price1,time2,price2))
return(false);
if(!Attach(chart_id,name,window,2))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectFiboTimes. |
//| Purpose: Class of the "Fibonacci Time Zones" object of chart |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectFiboTimes : public CChartObject
{
public:
CChartObjectFiboTimes(void);
~CChartObjectFiboTimes(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_FIBOTIMES); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectFiboTimes::CChartObjectFiboTimes(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectFiboTimes::~CChartObjectFiboTimes(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Fibonacci Time Zones" |
//+------------------------------------------------------------------+
bool CChartObjectFiboTimes::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2)
{
if(!ObjectCreate(chart_id,name,OBJ_FIBOTIMES,window,time1,price1,time2,price2))
return(false);
if(!Attach(chart_id,name,window,2))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectFiboFan. |
//| Purpose: Class of the "Fibonacci Fan" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectFiboFan : public CChartObject
{
public:
CChartObjectFiboFan(void);
~CChartObjectFiboFan(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_FIBOFAN); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectFiboFan::CChartObjectFiboFan(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectFiboFan::~CChartObjectFiboFan(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Fibonacci Fan" |
//+------------------------------------------------------------------+
bool CChartObjectFiboFan::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2)
{
if(!ObjectCreate(chart_id,name,OBJ_FIBOFAN,window,time1,price1,time2,price2))
return(false);
if(!Attach(chart_id,name,window,2))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectFiboArc. |
//| Purpose: Class of the "Fibonacci Arcs" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectFiboArc : public CChartObject
{
public:
CChartObjectFiboArc(void);
~CChartObjectFiboArc(void);
//--- methods of access to properties of the object
double Scale(void) const;
bool Scale(const double scale) const;
bool Ellipse(void) const;
bool Ellipse(const bool ellipse) const;
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,const double scale);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_FIBOARC); }
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectFiboArc::CChartObjectFiboArc(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectFiboArc::~CChartObjectFiboArc(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Fibonacci Arcs" |
//+------------------------------------------------------------------+
bool CChartObjectFiboArc::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,const double scale)
{
if(!ObjectCreate(chart_id,name,OBJ_FIBOARC,window,time1,price1,time2,price2))
return(false);
if(!Attach(chart_id,name,window,2))
return(false);
if(!Scale(scale))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get value of the "Scale" property |
//+------------------------------------------------------------------+
double CChartObjectFiboArc::Scale(void) const
{
//--- check
if(m_chart_id==-1)
return(EMPTY_VALUE);
//--- result
return(ObjectGetDouble(m_chart_id,m_name,OBJPROP_SCALE));
}
//+------------------------------------------------------------------+
//| Set value for the "Scale" property |
//+------------------------------------------------------------------+
bool CChartObjectFiboArc::Scale(const double scale) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetDouble(m_chart_id,m_name,OBJPROP_SCALE,scale));
}
//+------------------------------------------------------------------+
//| Get value of the "Ellipse" property |
//+------------------------------------------------------------------+
bool CChartObjectFiboArc::Ellipse(void) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_ELLIPSE));
}
//+------------------------------------------------------------------+
//| Set value for the "Ellipse" property |
//+------------------------------------------------------------------+
bool CChartObjectFiboArc::Ellipse(const bool ellipse) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_ELLIPSE,ellipse));
}
//+------------------------------------------------------------------+
//| Writing parameter of object to file |
//+------------------------------------------------------------------+
bool CChartObjectFiboArc::Save(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObject::Save(file_handle))
return(false);
//--- write value of the "Scale" property
if(FileWriteDouble(file_handle,ObjectGetDouble(m_chart_id,m_name,OBJPROP_SCALE))!=sizeof(double))
return(false);
//--- write value of the "Ellipse" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_ELLIPSE),CHAR_VALUE)!=sizeof(char))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading parameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectFiboArc::Load(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObject::Load(file_handle))
return(false);
//--- read value of the "Scale" property
if(!ObjectSetDouble(m_chart_id,m_name,OBJPROP_SCALE,FileReadDouble(file_handle)))
return(false);
//--- read value of the "Ellipse" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_ELLIPSE,FileReadInteger(file_handle,CHAR_VALUE)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectFiboChannel. |
//| Purpose: Class of the "Fibonacci Channel" object of chart. |
//| Derives from class CChartObjectTrend. |
//+------------------------------------------------------------------+
class CChartObjectFiboChannel : public CChartObjectTrend
{
public:
CChartObjectFiboChannel(void);
~CChartObjectFiboChannel(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_FIBOCHANNEL); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectFiboChannel::CChartObjectFiboChannel(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectFiboChannel::~CChartObjectFiboChannel(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Fibonacci Channel" |
//+------------------------------------------------------------------+
bool CChartObjectFiboChannel::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3)
{
if(!ObjectCreate(chart_id,name,OBJ_FIBOCHANNEL,window,time1,price1,time2,price2,time3,price3))
return(false);
if(!Attach(chart_id,name,window,3))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectFiboExpansion. |
//| Purpose: Class of the "Fibonacci Expansion" object. |
//| Derives from class CChartObjectTrend. |
//+------------------------------------------------------------------+
class CChartObjectFiboExpansion : public CChartObjectTrend
{
public:
CChartObjectFiboExpansion(void);
~CChartObjectFiboExpansion(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_EXPANSION); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectFiboExpansion::CChartObjectFiboExpansion(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectFiboExpansion::~CChartObjectFiboExpansion(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Fibonacci Expansion" |
//+------------------------------------------------------------------+
bool CChartObjectFiboExpansion::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3)
{
if(!ObjectCreate(chart_id,name,OBJ_EXPANSION,window,time1,price1,time2,price2,time3,price3))
return(false);
if(!Attach(chart_id,name,window,3))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
+390
View File
@@ -0,0 +1,390 @@
//+------------------------------------------------------------------+
//| ChartObjectsGann.mqh |
//| Copyright 2000-2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//| All Gann tools. |
//+------------------------------------------------------------------+
#include "ChartObjectsLines.mqh"
//+------------------------------------------------------------------+
//| Class CChartObjectGannLine. |
//| Purpose: Class of the "Gann Line" object of chart. |
//| Derives from class CChartObjectTrendByAngle. |
//+------------------------------------------------------------------+
class CChartObjectGannLine : public CChartObjectTrendByAngle
{
public:
CChartObjectGannLine(void);
~CChartObjectGannLine(void);
//--- methods of access to properties of the object
double PipsPerBar(void) const;
bool PipsPerBar(const double ppb) const;
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double ppb);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_GANNLINE); }
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectGannLine::CChartObjectGannLine(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectGannLine::~CChartObjectGannLine(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Gann Line" |
//+------------------------------------------------------------------+
bool CChartObjectGannLine::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double ppb)
{
if(!ObjectCreate(chart_id,name,OBJ_GANNLINE,window,time1,price1,time2,0.0))
return(false);
if(!Attach(chart_id,name,window,2))
return(false);
if(!PipsPerBar(ppb))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get value of the "PipsPerBar" property |
//+------------------------------------------------------------------+
double CChartObjectGannLine::PipsPerBar(void) const
{
//--- check
if(m_chart_id==-1)
return(EMPTY_VALUE);
//--- result
return(ObjectGetDouble(m_chart_id,m_name,OBJPROP_SCALE));
}
//+------------------------------------------------------------------+
//| Set value for the "PipsPerBar" property |
//+------------------------------------------------------------------+
bool CChartObjectGannLine::PipsPerBar(const double ppb) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetDouble(m_chart_id,m_name,OBJPROP_SCALE,ppb));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectGannLine::Save(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObjectTrend::Save(file_handle))
return(false);
//--- write value of the "PipsPerBar"
if(FileWriteDouble(file_handle,ObjectGetDouble(m_chart_id,m_name,OBJPROP_SCALE))!=sizeof(double))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading parameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectGannLine::Load(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObjectTrend::Load(file_handle))
return(false);
//--- read value of the "PipsPerBar" property
if(!ObjectSetDouble(m_chart_id,m_name,OBJPROP_SCALE,FileReadDouble(file_handle)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectGannFan. |
//| Purpose: Class of the "Gann Fan" object of chart. |
//| Derives from class CChartObjectTrend. |
//+------------------------------------------------------------------+
class CChartObjectGannFan : public CChartObjectTrend
{
public:
CChartObjectGannFan(void);
~CChartObjectGannFan(void);
//--- methods of access to properties of the object
double PipsPerBar(void) const;
bool PipsPerBar(const double ppb) const;
bool Downtrend(void) const;
bool Downtrend(const bool downtrend) const;
//--- method of create the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double ppb);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_GANNFAN); }
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectGannFan::CChartObjectGannFan(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectGannFan::~CChartObjectGannFan(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Gann Fan" |
//+------------------------------------------------------------------+
bool CChartObjectGannFan::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double ppb)
{
if(!ObjectCreate(chart_id,name,OBJ_GANNFAN,window,time1,price1,time2,0.0))
return(false);
if(!Attach(chart_id,name,window,2))
return(false);
if(!PipsPerBar(ppb))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get value of the "PipsPerBar" property |
//+------------------------------------------------------------------+
double CChartObjectGannFan::PipsPerBar(void) const
{
//--- check
if(m_chart_id==-1)
return(EMPTY_VALUE);
//--- result
return(ObjectGetDouble(m_chart_id,m_name,OBJPROP_SCALE));
}
//+------------------------------------------------------------------+
//| Set value for the "PipsPerBar" property |
//+------------------------------------------------------------------+
bool CChartObjectGannFan::PipsPerBar(const double ppb) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetDouble(m_chart_id,m_name,OBJPROP_SCALE,ppb));
}
//+------------------------------------------------------------------+
//| Get value of the "Downtrend" property |
//+------------------------------------------------------------------+
bool CChartObjectGannFan::Downtrend(void) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_DIRECTION));
}
//+------------------------------------------------------------------+
//| Set value for the "Downtrend" property |
//+------------------------------------------------------------------+
bool CChartObjectGannFan::Downtrend(const bool downtrend) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_DIRECTION,downtrend));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectGannFan::Save(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObjectTrend::Save(file_handle))
return(false);
//--- write value of the "PipsPerBar" property
if(FileWriteDouble(file_handle,ObjectGetDouble(m_chart_id,m_name,OBJPROP_SCALE))!=sizeof(double))
return(false);
//--- write value of the "Downtrend" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_DIRECTION),CHAR_VALUE)!=sizeof(char))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading object parameters from file |
//+------------------------------------------------------------------+
bool CChartObjectGannFan::Load(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObjectTrend::Load(file_handle))
return(false);
//--- read value of the "PipsPerBar" property
if(!ObjectSetDouble(m_chart_id,m_name,OBJPROP_SCALE,FileReadDouble(file_handle)))
return(false);
//--- read value of the "Downtrend" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_DIRECTION,FileReadInteger(file_handle,CHAR_VALUE)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectGannGrid. |
//| Purpose: Class of the "Gann Grid" object of chart. |
//| Derives from class CChartObjectTrend. |
//+------------------------------------------------------------------+
class CChartObjectGannGrid : public CChartObjectTrend
{
public:
CChartObjectGannGrid(void);
~CChartObjectGannGrid(void);
//--- methods of access to properties of the object
double PipsPerBar(void) const;
bool PipsPerBar(const double ppb) const;
bool Downtrend(void) const;
bool Downtrend(const bool downtrend) const;
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double ppb);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_GANNGRID); }
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectGannGrid::CChartObjectGannGrid(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectGannGrid::~CChartObjectGannGrid(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Gann Grid" |
//+------------------------------------------------------------------+
bool CChartObjectGannGrid::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double ppb)
{
if(!ObjectCreate(chart_id,name,OBJ_GANNGRID,window,time1,price1,time2,0.0))
return(false);
if(!Attach(chart_id,name,window,2))
return(false);
if(!PipsPerBar(ppb))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get value of the"PipsPerBar" property |
//+------------------------------------------------------------------+
double CChartObjectGannGrid::PipsPerBar(void) const
{
//--- check
if(m_chart_id==-1)
return(EMPTY_VALUE);
//--- result
return(ObjectGetDouble(m_chart_id,m_name,OBJPROP_SCALE));
}
//+------------------------------------------------------------------+
//| Set value for the "PipsPerBar" property |
//+------------------------------------------------------------------+
bool CChartObjectGannGrid::PipsPerBar(const double ppb) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetDouble(m_chart_id,m_name,OBJPROP_SCALE,ppb));
}
//+------------------------------------------------------------------+
//| Get the property value "Downtrend" |
//+------------------------------------------------------------------+
bool CChartObjectGannGrid::Downtrend(void) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_DIRECTION));
}
//+------------------------------------------------------------------+
//| Set the property value "Downtrend" |
//+------------------------------------------------------------------+
bool CChartObjectGannGrid::Downtrend(const bool downtrend) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_DIRECTION,downtrend));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectGannGrid::Save(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObjectTrend::Save(file_handle))
return(false);
//--- write value of the "PipsPerBar" property
if(FileWriteDouble(file_handle,ObjectGetDouble(m_chart_id,m_name,OBJPROP_SCALE))!=sizeof(double))
return(false);
//--- write value of the "Downtrend" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_DIRECTION),CHAR_VALUE)!=sizeof(char))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading paprameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectGannGrid::Load(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObjectTrend::Load(file_handle))
return(false);
//--- read value of the "PipsPerBar" property
if(!ObjectSetDouble(m_chart_id,m_name,OBJPROP_SCALE,FileReadDouble(file_handle)))
return(false);
//--- read value of the "Downtrend" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_DIRECTION,FileReadInteger(file_handle,CHAR_VALUE)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
+335
View File
@@ -0,0 +1,335 @@
//+------------------------------------------------------------------+
//| ChartObjectsLines.mqh |
//| Copyright 2000-2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//| All lines. |
//+------------------------------------------------------------------+
#include "ChartObject.mqh"
//+------------------------------------------------------------------+
//| Class CChartObjectVLine. |
//| Purpose: Class of the "Vertical line" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectVLine : public CChartObject
{
public:
CChartObjectVLine(void);
~CChartObjectVLine(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const datetime time);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_VLINE); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectVLine::CChartObjectVLine(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectVLine::~CChartObjectVLine(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Vertical line" |
//+------------------------------------------------------------------+
bool CChartObjectVLine::Create(long chart_id,const string name,const int window,const datetime time)
{
if(!ObjectCreate(chart_id,name,OBJ_VLINE,window,time,0.0))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectHLine. |
//| Purpose: Class of the "Horizontal line" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectHLine : public CChartObject
{
public:
CChartObjectHLine(void);
~CChartObjectHLine(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const double price);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_HLINE); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectHLine::CChartObjectHLine(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectHLine::~CChartObjectHLine(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Horizontal line" |
//+------------------------------------------------------------------+
bool CChartObjectHLine::Create(long chart_id,const string name,const int window,const double price)
{
if(!ObjectCreate(chart_id,name,OBJ_HLINE,window,0,price))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectTrend. |
//| Purpose: Class of the "Trendline" object of chart. |
//| Derives from class CChartObject. |
//| It is the parent class for all objects that have properties |
//| RAY_LEFT and RAY_RIGHT. |
//+------------------------------------------------------------------+
class CChartObjectTrend : public CChartObject
{
public:
CChartObjectTrend(void);
~CChartObjectTrend(void);
//--- methods of access to properties of the object
bool RayLeft(void) const;
bool RayLeft(const bool new_sel) const;
bool RayRight(void) const;
bool RayRight(const bool new_sel) const;
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_TREND); }
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectTrend::CChartObjectTrend(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectTrend::~CChartObjectTrend(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Trendline" |
//+------------------------------------------------------------------+
bool CChartObjectTrend::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2)
{
if(!ObjectCreate(chart_id,name,OBJ_TREND,window,time1,price1,time2,price2))
return(false);
if(!Attach(chart_id,name,window,2))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get the "Ray left" flag |
//+------------------------------------------------------------------+
bool CChartObjectTrend::RayLeft(void) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_RAY_LEFT));
}
//+------------------------------------------------------------------+
//| Set the "Ray left" flag |
//+------------------------------------------------------------------+
bool CChartObjectTrend::RayLeft(const bool new_ray) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_RAY_LEFT,new_ray));
}
//+------------------------------------------------------------------+
//| Get the "Ray right" flag |
//+------------------------------------------------------------------+
bool CChartObjectTrend::RayRight(void) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_RAY_RIGHT));
}
//+------------------------------------------------------------------+
//| Set the "Ray right" flag |
//+------------------------------------------------------------------+
bool CChartObjectTrend::RayRight(const bool new_ray) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_RAY_RIGHT,new_ray));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectTrend::Save(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObject::Save(file_handle))
return(false);
//--- write value of the "Ray left" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_RAY_LEFT),CHAR_VALUE)!=sizeof(char))
return(false);
//--- write value of the "Ray right" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_RAY_RIGHT),CHAR_VALUE)!=sizeof(char))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading parameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectTrend::Load(const int file_handle)
{
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObject::Load(file_handle))
return(false);
//--- read value of the "Ray left" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_RAY_LEFT,FileReadInteger(file_handle,CHAR_VALUE)))
return(false);
//--- read value of the "Ray right" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_RAY_RIGHT,FileReadInteger(file_handle,CHAR_VALUE)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectTrendByAngle. |
//| Puprose: Class of the "Trendline by angle" object of chart. |
//| Derives from class CChartObjectTrend. |
//+------------------------------------------------------------------+
class CChartObjectTrendByAngle : public CChartObjectTrend
{
public:
CChartObjectTrendByAngle(void);
~CChartObjectTrendByAngle(void);
//--- methods of access to properties of the object
double Angle(void) const;
bool Angle(const double angle) const;
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_TRENDBYANGLE); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectTrendByAngle::CChartObjectTrendByAngle(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectTrendByAngle::~CChartObjectTrendByAngle(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Trendline by angle" |
//+------------------------------------------------------------------+
bool CChartObjectTrendByAngle::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2)
{
if(!ObjectCreate(chart_id,name,OBJ_TRENDBYANGLE,window,time1,price1,time2,price2))
return(false);
if(!Attach(chart_id,name,window,2))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get the "Angle" property |
//+------------------------------------------------------------------+
double CChartObjectTrendByAngle::Angle(void) const
{
//--- check
if(m_chart_id==-1)
return(EMPTY_VALUE);
//---
return(ObjectGetDouble(m_chart_id,m_name,OBJPROP_ANGLE));
}
//+------------------------------------------------------------------+
//| Set the "Angle" property |
//+------------------------------------------------------------------+
bool CChartObjectTrendByAngle::Angle(const double angle) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetDouble(m_chart_id,m_name,OBJPROP_ANGLE,angle));
}
//+------------------------------------------------------------------+
//| Class CChartObjectCycles. |
//| Purpose: Class of the "Cycle lines" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectCycles : public CChartObject
{
public:
CChartObjectCycles(void);
~CChartObjectCycles(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_CYCLES); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectCycles::CChartObjectCycles(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectCycles::~CChartObjectCycles(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Cycle lines" |
//+------------------------------------------------------------------+
bool CChartObjectCycles::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2)
{
if(!ObjectCreate(chart_id,name,OBJ_CYCLES,window,time1,price1,time2,price2))
return(false);
if(!Attach(chart_id,name,window,2))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
+142
View File
@@ -0,0 +1,142 @@
//+------------------------------------------------------------------+
//| ChartObjectsShapes.mqh |
//| Copyright 2000-2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//| All shapes. |
//+------------------------------------------------------------------+
#include "ChartObject.mqh"
//+------------------------------------------------------------------+
//| Class CChartObjectRectangle. |
//| Purpose: Class of the "Rectangle" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectRectangle : public CChartObject
{
public:
CChartObjectRectangle(void);
~CChartObjectRectangle(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_RECTANGLE); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectRectangle::CChartObjectRectangle(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectRectangle::~CChartObjectRectangle(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Rectangle" |
//+------------------------------------------------------------------+
bool CChartObjectRectangle::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2)
{
if(!ObjectCreate(chart_id,name,OBJ_RECTANGLE,window,time1,price1,time2,price2))
return(false);
if(!Attach(chart_id,name,window,2))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectTriangle. |
//| Purpose: Class of the "Triangle" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectTriangle : public CChartObject
{
public:
CChartObjectTriangle(void);
~CChartObjectTriangle(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_TRIANGLE); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectTriangle::CChartObjectTriangle(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectTriangle::~CChartObjectTriangle(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Triangle" |
//+------------------------------------------------------------------+
bool CChartObjectTriangle::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3)
{
if(!ObjectCreate(chart_id,name,OBJ_TRIANGLE,window,time1,price1,time2,price2,time3,price3))
return(false);
if(!Attach(chart_id,name,window,3))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectEllipse. |
//| Purpose: Class of the "Ellipse" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectEllipse : public CChartObject
{
public:
CChartObjectEllipse(void);
~CChartObjectEllipse(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_ELLIPSE); }
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectEllipse::CChartObjectEllipse(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectEllipse::~CChartObjectEllipse(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Ellipse" |
//+------------------------------------------------------------------+
bool CChartObjectEllipse::Create(long chart_id,const string name,const int window,
const datetime time1,const double price1,
const datetime time2,const double price2,
const datetime time3,const double price3)
{
if(!ObjectCreate(chart_id,name,OBJ_ELLIPSE,window,time1,price1,time2,price2,time3,price3))
return(false);
if(!Attach(chart_id,name,window,3))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
+895
View File
@@ -0,0 +1,895 @@
//+------------------------------------------------------------------+
//| ChartObjectsTxtControls.mqh |
//| Copyright 2000-2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
//| All text objects. |
//+------------------------------------------------------------------+
#include "ChartObject.mqh"
//+------------------------------------------------------------------+
//| Class CChartObjectText. |
//| Purpose: Class of the "Text" object of chart. |
//| Derives from class CChartObject. |
//+------------------------------------------------------------------+
class CChartObjectText : public CChartObject
{
public:
CChartObjectText(void);
~CChartObjectText(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const datetime time,const double price);
//--- method of identifying the object
virtual int Type(void) const override { return(OBJ_TEXT); }
//--- methods of access to properties of the object
double Angle(void) const;
bool Angle(const double angle) const;
string Font(void) const;
bool Font(const string font) const;
int FontSize(void) const;
bool FontSize(const int size) const;
ENUM_ANCHOR_POINT Anchor(void) const;
bool Anchor(const ENUM_ANCHOR_POINT anchor) const;
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectText::CChartObjectText(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectText::~CChartObjectText(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Text" |
//+------------------------------------------------------------------+
bool CChartObjectText::Create(long chart_id,const string name,const int window,
const datetime time,const double price)
{
if(!ObjectCreate(chart_id,name,OBJ_TEXT,window,time,price))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get value of the "Angle" property |
//+------------------------------------------------------------------+
double CChartObjectText::Angle(void) const
{
//--- check
if(m_chart_id==-1)
return(EMPTY_VALUE);
//--- result
return(ObjectGetDouble(m_chart_id,m_name,OBJPROP_ANGLE));
}
//+------------------------------------------------------------------+
//| Set value of the "Angle" property |
//+------------------------------------------------------------------+
bool CChartObjectText::Angle(const double angle) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetDouble(m_chart_id,m_name,OBJPROP_ANGLE,angle));
}
//+------------------------------------------------------------------+
//| Get font name |
//+------------------------------------------------------------------+
string CChartObjectText::Font(void) const
{
//--- check
if(m_chart_id==-1)
return("");
//--- result
return(ObjectGetString(m_chart_id,m_name,OBJPROP_FONT));
}
//+------------------------------------------------------------------+
//| Set font name |
//+------------------------------------------------------------------+
bool CChartObjectText::Font(const string font) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetString(m_chart_id,m_name,OBJPROP_FONT,font));
}
//+------------------------------------------------------------------+
//| Get font size |
//+------------------------------------------------------------------+
int CChartObjectText::FontSize(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_FONTSIZE));
}
//+------------------------------------------------------------------+
//| Set font size |
//+------------------------------------------------------------------+
bool CChartObjectText::FontSize(const int size) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_FONTSIZE,size));
}
//+------------------------------------------------------------------+
//| Get anchor point |
//+------------------------------------------------------------------+
ENUM_ANCHOR_POINT CChartObjectText::Anchor(void) const
{
//--- check
if(m_chart_id==-1)
return(WRONG_VALUE);
//--- result
return((ENUM_ANCHOR_POINT)ObjectGetInteger(m_chart_id,m_name,OBJPROP_ANCHOR));
}
//+------------------------------------------------------------------+
//| Set anchor point |
//+------------------------------------------------------------------+
bool CChartObjectText::Anchor(const ENUM_ANCHOR_POINT anchor) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_ANCHOR,anchor));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectText::Save(const int file_handle)
{
int len;
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObject::Save(file_handle))
return(false);
//--- write value of the "Angle" property
if(FileWriteDouble(file_handle,ObjectGetDouble(m_chart_id,m_name,OBJPROP_ANGLE))!=sizeof(double))
return(false);
//--- write value of the "Font Name" property
str=ObjectGetString(m_chart_id,m_name,OBJPROP_FONT);
len=StringLen(str);
if(FileWriteInteger(file_handle,len,INT_VALUE)!=INT_VALUE)
return(false);
if(len!=0 && FileWriteString(file_handle,str,len)!=len)
return(false);
//--- write value of the "Font Size" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_FONTSIZE),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "Anchor Point" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_ANCHOR),INT_VALUE)!=sizeof(int))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading parameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectText::Load(const int file_handle)
{
int len;
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObject::Load(file_handle))
return(false);
//--- reading value of the "Angle" property
if(!ObjectSetDouble(m_chart_id,m_name,OBJPROP_ANGLE,0,FileReadDouble(file_handle)))
return(false);
//--- read value of the "Font Name" property
len=FileReadInteger(file_handle,INT_VALUE);
str=(len!=0) ? FileReadString(file_handle,len) : "";
if(!ObjectSetString(m_chart_id,m_name,OBJPROP_FONT,str))
return(false);
//--- read value of the "Font Size" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_FONTSIZE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "Anchor Point" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_ANCHOR,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectLabel. |
//| Purpose: Class of the "Label" object of chart. |
//| Derives from class CChartObjectText. |
//+------------------------------------------------------------------+
class CChartObjectLabel : public CChartObjectText
{
public:
CChartObjectLabel(void);
~CChartObjectLabel(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const int X,const int Y);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_LABEL); }
//--- methods of access to properties of the object
int X_Distance(void) const;
bool X_Distance(const int X) const;
int Y_Distance(void) const;
bool Y_Distance(const int Y) const;
int X_Size(void) const;
int Y_Size(void) const;
ENUM_BASE_CORNER Corner(void) const;
bool Corner(const ENUM_BASE_CORNER corner) const;
//--- change of time/price coordinates is blocked
datetime Time(const int point) const { return(CChartObjectText::Time(point)); }
bool Time(const int point,const datetime time) const { return(false); }
double Price(const int point) const { return(CChartObjectText::Price(point)); }
bool Price(const int point,const double price) const { return(false); }
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectLabel::CChartObjectLabel(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectLabel::~CChartObjectLabel(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Label" |
//+------------------------------------------------------------------+
bool CChartObjectLabel::Create(long chart_id,const string name,const int window,const int X,const int Y)
{
if(!ObjectCreate(chart_id,name,OBJ_LABEL,window,0,0.0))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
if(!Description(name))
return(false);
if(!X_Distance(X) || !Y_Distance(Y))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Get the X-distance |
//+------------------------------------------------------------------+
int CChartObjectLabel::X_Distance(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XDISTANCE));
}
//+------------------------------------------------------------------+
//| Set the X-distance |
//+------------------------------------------------------------------+
bool CChartObjectLabel::X_Distance(const int X) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_XDISTANCE,X));
}
//+------------------------------------------------------------------+
//| Get the Y-distance |
//+------------------------------------------------------------------+
int CChartObjectLabel::Y_Distance(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YDISTANCE));
}
//+------------------------------------------------------------------+
//| Set the Y-distance |
//+------------------------------------------------------------------+
bool CChartObjectLabel::Y_Distance(const int Y) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_YDISTANCE,Y));
}
//+------------------------------------------------------------------+
//| Get the X-size |
//+------------------------------------------------------------------+
int CChartObjectLabel::X_Size(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XSIZE));
}
//+------------------------------------------------------------------+
//| Get the Y-size |
//+------------------------------------------------------------------+
int CChartObjectLabel::Y_Size(void) const
{
//--- check
if(m_chart_id==-1)
return(0);
//--- result
return((int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YSIZE));
}
//+------------------------------------------------------------------+
//| Get base corner |
//+------------------------------------------------------------------+
ENUM_BASE_CORNER CChartObjectLabel::Corner(void) const
{
//--- check
if(m_chart_id==-1)
return(WRONG_VALUE);
//--- result
return((ENUM_BASE_CORNER)ObjectGetInteger(m_chart_id,m_name,OBJPROP_CORNER));
}
//+------------------------------------------------------------------+
//| Set base corner |
//+------------------------------------------------------------------+
bool CChartObjectLabel::Corner(const ENUM_BASE_CORNER corner) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_CORNER,corner));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectLabel::Save(const int file_handle)
{
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObjectText::Save(file_handle))
return(false);
//--- write value of the "X-distance" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XDISTANCE),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "Y-distance" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YDISTANCE),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "Corner" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_CORNER),INT_VALUE)!=sizeof(int))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading parameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectLabel::Load(const int file_handle)
{
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObjectText::Load(file_handle))
return(false);
//--- reading value of the "X-distance" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_XDISTANCE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "Y-distance" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_YDISTANCE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "Corner" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_CORNER,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectEdit. |
//| Purpose: Class of the "Edit" object of chart. |
//| Derives from class CChartObjectLabel. |
//+------------------------------------------------------------------+
class CChartObjectEdit : public CChartObjectLabel
{
public:
CChartObjectEdit(void);
~CChartObjectEdit(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const int X,const int Y,const int sizeX,const int sizeY);
//--- method of identifying the object
virtual int Type(void) const override { return(OBJ_EDIT); }
//--- methods of access to properties of the object
bool X_Size(const int X) const;
int X_Size(void) const { return(CChartObjectLabel::X_Size()); }
bool Y_Size(const int Y) const;
int Y_Size(void) const { return(CChartObjectLabel::Y_Size()); }
color BackColor(void) const;
bool BackColor(const color new_color) const;
color BorderColor(void) const;
bool BorderColor(const color new_color) const;
bool ReadOnly(void) const;
bool ReadOnly(const bool flag) const;
ENUM_ALIGN_MODE TextAlign(void) const;
bool TextAlign(const ENUM_ALIGN_MODE align) const;
//--- change of angle is blocked
bool Angle(const double angle) const { return(false); }
double Angle(void) const { return(CChartObjectLabel::Angle()); }
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectEdit::CChartObjectEdit(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectEdit::~CChartObjectEdit(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Edit" |
//+------------------------------------------------------------------+
bool CChartObjectEdit::Create(long chart_id,const string name,const int window,const int X,const int Y,const int sizeX,const int sizeY)
{
if(!ObjectCreate(chart_id,name,(ENUM_OBJECT)Type(),window,0,0,0))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
if(!X_Distance(X) || !Y_Distance(Y))
return(false);
if(!X_Size(sizeX) || !Y_Size(sizeY))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Set X-size |
//+------------------------------------------------------------------+
bool CChartObjectEdit::X_Size(const int X) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_XSIZE,X));
}
//+------------------------------------------------------------------+
//| Set Y-size |
//+------------------------------------------------------------------+
bool CChartObjectEdit::Y_Size(const int Y) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_YSIZE,Y));
}
//+------------------------------------------------------------------+
//| Get background color |
//+------------------------------------------------------------------+
color CChartObjectEdit::BackColor(void) const
{
//--- check
if(m_chart_id==-1)
return(CLR_NONE);
//--- result
return((color)ObjectGetInteger(m_chart_id,m_name,OBJPROP_BGCOLOR));
}
//+------------------------------------------------------------------+
//| Set background color |
//+------------------------------------------------------------------+
bool CChartObjectEdit::BackColor(const color new_color) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_BGCOLOR,new_color));
}
//+------------------------------------------------------------------+
//| Get border color |
//+------------------------------------------------------------------+
color CChartObjectEdit::BorderColor(void) const
{
//--- check
if(m_chart_id==-1)
return(CLR_NONE);
//--- result
return((color)ObjectGetInteger(m_chart_id,m_name,OBJPROP_BORDER_COLOR));
}
//+------------------------------------------------------------------+
//| Set border color |
//+------------------------------------------------------------------+
bool CChartObjectEdit::BorderColor(const color new_color) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_BORDER_COLOR,new_color));
}
//+------------------------------------------------------------------+
//| Get the "Read only" property |
//+------------------------------------------------------------------+
bool CChartObjectEdit::ReadOnly(void) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_READONLY));
}
//+------------------------------------------------------------------+
//| Set the "Read only" property |
//+------------------------------------------------------------------+
bool CChartObjectEdit::ReadOnly(const bool flag) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_READONLY,flag));
}
//+------------------------------------------------------------------+
//| Get the "Align" property |
//+------------------------------------------------------------------+
ENUM_ALIGN_MODE CChartObjectEdit::TextAlign(void) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return((ENUM_ALIGN_MODE)ObjectGetInteger(m_chart_id,m_name,OBJPROP_ALIGN));
}
//+------------------------------------------------------------------+
//| Set the "Align" property |
//+------------------------------------------------------------------+
bool CChartObjectEdit::TextAlign(const ENUM_ALIGN_MODE align) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_ALIGN,align));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectEdit::Save(const int file_handle)
{
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObjectLabel::Save(file_handle))
return(false);
//--- write value of the "X-size" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XSIZE),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "Y-size" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YSIZE),INT_VALUE)!=sizeof(int))
return(false);
//--- write background color
if(FileWriteLong(file_handle,ObjectGetInteger(m_chart_id,m_name,OBJPROP_BGCOLOR))!=sizeof(long))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading parameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectEdit::Load(const int file_handle)
{
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObjectLabel::Load(file_handle))
return(false);
//--- read value of the "X-size" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_XSIZE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "Y-size" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_YSIZE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read background color
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_BGCOLOR,FileReadLong(file_handle)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectButton. |
//| Purpose: Class of the "Button" object of chart. |
//| Derives from class CChartObjectEdit. |
//+------------------------------------------------------------------+
class CChartObjectButton : public CChartObjectEdit
{
public:
CChartObjectButton(void);
~CChartObjectButton(void);
//--- method of identifying the object
virtual int Type(void) const override { return(OBJ_BUTTON); }
//--- methods of access to properties of the object
bool State(void) const;
bool State(const bool state) const;
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectButton::CChartObjectButton(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectButton::~CChartObjectButton(void)
{
}
//+------------------------------------------------------------------+
//| Get state |
//+------------------------------------------------------------------+
bool CChartObjectButton::State(void) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return((bool)ObjectGetInteger(m_chart_id,m_name,OBJPROP_STATE));
}
//+------------------------------------------------------------------+
//| Set state |
//+------------------------------------------------------------------+
bool CChartObjectButton::State(const bool state) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_STATE,state));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectButton::Save(const int file_handle)
{
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObjectEdit::Save(file_handle))
return(false);
//--- write state
if(FileWriteLong(file_handle,ObjectGetInteger(m_chart_id,m_name,OBJPROP_STATE))!=sizeof(long))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading parameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectButton::Load(const int file_handle)
{
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObjectEdit::Load(file_handle))
return(false);
//--- read state
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_STATE,FileReadLong(file_handle)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Class CChartObjectRectLabel. |
//| Purpose: Class of the "Rectangle Label" object of chart. |
//| Derives from class CChartObjectLabel. |
//+------------------------------------------------------------------+
class CChartObjectRectLabel : public CChartObjectLabel
{
public:
CChartObjectRectLabel(void);
~CChartObjectRectLabel(void);
//--- method of creating the object
bool Create(long chart_id,const string name,const int window,const int X,const int Y,const int sizeX,const int sizeY);
//--- method of identifying the object
virtual int Type(void) const { return(OBJ_RECTANGLE_LABEL); }
//--- methods of access to properties of the object
bool X_Size(const int X) const;
int X_Size(void)const { return(CChartObjectLabel::X_Size()); }
bool Y_Size(const int Y) const;
int Y_Size(void)const { return(CChartObjectLabel::Y_Size()); }
color BackColor(void) const;
bool BackColor(const color new_color) const;
ENUM_BORDER_TYPE BorderType(void) const;
bool BorderType(const ENUM_BORDER_TYPE flag) const;
//--- change of angle is blocked
bool Angle(const double angle) const { return(false); }
double Angle(void) const { return(CChartObjectLabel::Angle()); }
//--- methods for working with files
virtual bool Save(const int file_handle);
virtual bool Load(const int file_handle);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CChartObjectRectLabel::CChartObjectRectLabel(void)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CChartObjectRectLabel::~CChartObjectRectLabel(void)
{
}
//+------------------------------------------------------------------+
//| Create object "Ractangle Label" |
//+------------------------------------------------------------------+
bool CChartObjectRectLabel::Create(long chart_id,const string name,const int window,const int X,const int Y,const int sizeX,const int sizeY)
{
if(!ObjectCreate(chart_id,name,(ENUM_OBJECT)Type(),window,0,0,0))
return(false);
if(!Attach(chart_id,name,window,1))
return(false);
if(!X_Distance(X) || !Y_Distance(Y))
return(false);
if(!X_Size(sizeX) || !Y_Size(sizeY))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Set X-size |
//+------------------------------------------------------------------+
bool CChartObjectRectLabel::X_Size(const int X) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_XSIZE,X));
}
//+------------------------------------------------------------------+
//| Set Y-size |
//+------------------------------------------------------------------+
bool CChartObjectRectLabel::Y_Size(const int Y) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_YSIZE,Y));
}
//+------------------------------------------------------------------+
//| Get background color |
//+------------------------------------------------------------------+
color CChartObjectRectLabel::BackColor(void) const
{
//--- check
if(m_chart_id==-1)
return(CLR_NONE);
//--- result
return((color)ObjectGetInteger(m_chart_id,m_name,OBJPROP_BGCOLOR));
}
//+------------------------------------------------------------------+
//| Set background color |
//+------------------------------------------------------------------+
bool CChartObjectRectLabel::BackColor(const color new_color) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_BGCOLOR,new_color));
}
//+------------------------------------------------------------------+
//| Get the "Border type" property |
//+------------------------------------------------------------------+
ENUM_BORDER_TYPE CChartObjectRectLabel::BorderType(void) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return((ENUM_BORDER_TYPE)ObjectGetInteger(m_chart_id,m_name,OBJPROP_BORDER_TYPE));
}
//+------------------------------------------------------------------+
//| Set the "Border type" property |
//+------------------------------------------------------------------+
bool CChartObjectRectLabel::BorderType(const ENUM_BORDER_TYPE type) const
{
//--- check
if(m_chart_id==-1)
return(false);
//--- result
return(ObjectSetInteger(m_chart_id,m_name,OBJPROP_BORDER_TYPE,type));
}
//+------------------------------------------------------------------+
//| Writing parameters of object to file |
//+------------------------------------------------------------------+
bool CChartObjectRectLabel::Save(const int file_handle)
{
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- write
if(!CChartObjectLabel::Save(file_handle))
return(false);
//--- write value of the "X-size" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_XSIZE),INT_VALUE)!=sizeof(int))
return(false);
//--- write value of the "Y-size" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_YSIZE),INT_VALUE)!=sizeof(int))
return(false);
//--- write background color
if(FileWriteLong(file_handle,ObjectGetInteger(m_chart_id,m_name,OBJPROP_BGCOLOR))!=sizeof(long))
return(false);
//--- write value of the "Border type" property
if(FileWriteInteger(file_handle,(int)ObjectGetInteger(m_chart_id,m_name,OBJPROP_BORDER_TYPE),INT_VALUE)!=sizeof(int))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
//| Reading parameters of object from file |
//+------------------------------------------------------------------+
bool CChartObjectRectLabel::Load(const int file_handle)
{
string str;
//--- check
if(file_handle==INVALID_HANDLE || m_chart_id==-1)
return(false);
//--- read
if(!CChartObjectLabel::Load(file_handle))
return(false);
//--- read value of the "X-size" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_XSIZE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read value of the "Y-size" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_YSIZE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- read background color
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_BGCOLOR,FileReadLong(file_handle)))
return(false);
//--- read value of the "Border type" property
if(!ObjectSetInteger(m_chart_id,m_name,OBJPROP_BORDER_TYPE,FileReadInteger(file_handle,INT_VALUE)))
return(false);
//--- successful
return(true);
}
//+------------------------------------------------------------------+
+1549
View File
File diff suppressed because it is too large Load Diff