Consolidate Python ignore rules into root gitignore
This commit is contained in:
@@ -0,0 +1,260 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Axis.mqh |
|
||||
//| Copyright 2000-2026, MetaQuotes Ltd. |
|
||||
//| www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
typedef string(*DoubleToStringFunction)(double,void*);
|
||||
//--- Various axis types
|
||||
enum ENUM_AXIS_TYPE
|
||||
{
|
||||
AXIS_TYPE_DOUBLE,
|
||||
AXIS_TYPE_DATETIME,
|
||||
AXIS_TYPE_CUSTOM,
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CAxis |
|
||||
//| Usage: class for create axes on a two-dimensional graphics |
|
||||
//+------------------------------------------------------------------+
|
||||
class CAxis
|
||||
{
|
||||
private:
|
||||
double m_min;
|
||||
double m_max;
|
||||
double m_step;
|
||||
uint m_clr;
|
||||
string m_name;
|
||||
int m_name_size;
|
||||
int m_values_size;
|
||||
int m_values_width;
|
||||
string m_values_format;
|
||||
string m_values_fontname;
|
||||
uint m_values_fontflags;
|
||||
uint m_values_fontangle;
|
||||
bool m_auto_scale;
|
||||
double m_zero_lever; // this number is used to determine when an axis scale range should be extended to include the zero value.
|
||||
double m_default_step; // length of the default step
|
||||
double m_max_labels; // the maximum number of marks
|
||||
double m_min_grace; // "grace" value applied to the minimum data range
|
||||
double m_max_grace; // "grace" value applied to the maximum data range
|
||||
int m_values_dt_mode;
|
||||
DoubleToStringFunction m_values_func;
|
||||
void *m_values_cbdata;
|
||||
ENUM_AXIS_TYPE m_type;
|
||||
|
||||
public:
|
||||
CAxis(void);
|
||||
~CAxis(void);
|
||||
//--- properties
|
||||
double Step(void) const { return(m_step); }
|
||||
double Min(void) const { return(m_min); }
|
||||
void Min(const double min) { m_min=min; }
|
||||
double Max(void) const { return(m_max); }
|
||||
void Max(const double max) { m_max=max; }
|
||||
string Name(void) const { return(m_name); }
|
||||
void Name(const string name) { m_name=name; }
|
||||
ENUM_AXIS_TYPE Type(void) const { return(m_type); }
|
||||
void Type(ENUM_AXIS_TYPE type) { m_type=type; }
|
||||
//--- default properties
|
||||
uint Color(void) const { return(m_clr); }
|
||||
void Color(const uint clr) { m_clr=clr; }
|
||||
bool AutoScale(void) const { return(m_auto_scale); }
|
||||
void AutoScale(const bool auto) { m_auto_scale=auto; }
|
||||
int ValuesSize(void) const { return(m_values_size); }
|
||||
void ValuesSize(const int size) { m_values_size=size; }
|
||||
int ValuesWidth(void) const { return(m_values_width); }
|
||||
void ValuesWidth(const int width) { m_values_width=width; }
|
||||
string ValuesFormat(void) const { return(m_values_format); }
|
||||
void ValuesFormat(const string format) { m_values_format=format; }
|
||||
int ValuesDateTimeMode(void) const { return(m_values_dt_mode); }
|
||||
void ValuesDateTimeMode(const int mode) { m_values_dt_mode=mode; }
|
||||
DoubleToStringFunction ValuesFunctionFormat(void) const { return(m_values_func); }
|
||||
void ValuesFunctionFormat(DoubleToStringFunction func) { m_values_func=func; }
|
||||
void *ValuesFunctionFormatCBData(void) const { return(m_values_cbdata); }
|
||||
void ValuesFunctionFormatCBData(void *cbdata) { m_values_cbdata=cbdata; }
|
||||
string ValuesFontName(void) const { return(m_values_fontname); }
|
||||
void ValuesFontName(const string fontname) { m_values_fontname=fontname; }
|
||||
uint ValuesFontAngle(void) const { return(m_values_fontangle); }
|
||||
void ValuesFontAngle(const uint fontangle) { m_values_fontangle=fontangle; }
|
||||
uint ValuesFontFlags(void) const { return(m_values_fontflags); }
|
||||
void ValuesFontFlags(const uint fontflags) { m_values_fontflags=fontflags; }
|
||||
int NameSize(void) const { return(m_name_size); }
|
||||
void NameSize(const int size) { m_name_size=size; }
|
||||
double ZeroLever(void) const { return(m_zero_lever); }
|
||||
void ZeroLever(const double value) { m_zero_lever=value; }
|
||||
double DefaultStep(void) const { return(m_default_step); }
|
||||
void DefaultStep(const double value) { m_default_step=value; }
|
||||
double MaxLabels(void) const { return(m_max_labels); }
|
||||
void MaxLabels(const double value) { m_max_labels=value; }
|
||||
double MinGrace(void) const { return(m_min_grace); }
|
||||
void MinGrace(const double value) { m_min_grace=value; }
|
||||
double MaxGrace(void) const { return(m_max_grace); }
|
||||
void MaxGrace(const double value) { m_max_grace=value; }
|
||||
//--- method for auto scaling
|
||||
void SelectAxisScale(void);
|
||||
|
||||
private:
|
||||
//--- additional methods for axis autoscaling
|
||||
void ExtensionBoundaries(void);
|
||||
double CalcStepSize(const double range,const double steps);
|
||||
double Mod(const double x,const double y);
|
||||
double CalcBoundedStepSize(const double range,const double max_steps);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CAxis::CAxis(void) : m_auto_scale(true),
|
||||
m_zero_lever(0.25),
|
||||
m_default_step(25.0),
|
||||
m_max_labels(15),
|
||||
m_min_grace(0.01),
|
||||
m_max_grace(0.01),
|
||||
m_clr(clrBlack),
|
||||
m_name_size(0),
|
||||
m_values_size(12),
|
||||
m_values_fontname("arial"),
|
||||
m_values_fontflags(0),
|
||||
m_values_fontangle(0),
|
||||
m_values_func(NULL),
|
||||
m_values_cbdata(NULL),
|
||||
m_values_dt_mode(TIME_MINUTES),
|
||||
m_type(AXIS_TYPE_DOUBLE),
|
||||
m_values_width(30)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CAxis::~CAxis(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Rounds a maximum, minimum values and defines step size. |
|
||||
//+------------------------------------------------------------------+
|
||||
void CAxis::SelectAxisScale(void)
|
||||
{
|
||||
if(m_min>m_max)
|
||||
m_max=m_min;
|
||||
if(!m_auto_scale)
|
||||
{
|
||||
if(m_max<=m_min)
|
||||
ExtensionBoundaries();
|
||||
m_step=((m_max-m_min)>m_default_step && m_default_step>0) ? m_default_step : m_max-m_min;
|
||||
return;
|
||||
}
|
||||
ExtensionBoundaries();
|
||||
//--- test for trivial condition of range = 0 and pick a suitable default
|
||||
if(m_max-m_min<1.0e-30)
|
||||
{
|
||||
m_max=m_max+0.2 *(m_max==0 ? 1.0 : MathAbs(m_max));
|
||||
m_min=m_min-0.2 *(m_min==0 ? 1.0 : MathAbs(m_min));
|
||||
}
|
||||
//--- this is the zero-lever test. If m_min is within the zero lever fraction of the data range,then use zero.
|
||||
if(m_min>0 && m_min/(m_max-m_min)<m_zero_lever)
|
||||
m_min=0;
|
||||
//--- repeat the zero-lever test for cases where the m_max is less than zero
|
||||
if(m_max<0 && MathAbs(m_max/(m_max-m_min))<m_zero_lever)
|
||||
m_max=0;
|
||||
//--- calculate the new m_step size
|
||||
double target_step=(m_default_step!=0) ? m_default_step : m_max-m_min;
|
||||
//--- Calculate the m_step size based on target steps
|
||||
m_step=CalcStepSize(m_max-m_min,target_step);
|
||||
double labels=MathCeil((m_max-m_min)/m_step);
|
||||
if(m_max_labels<labels && m_max_labels>0)
|
||||
m_step=CalcBoundedStepSize(m_max-m_min,m_max_labels);
|
||||
else
|
||||
m_step=CalcBoundedStepSize(m_max-m_min,labels);
|
||||
//--- calculate the scale minimum
|
||||
m_min=m_min-Mod(m_min,m_step);
|
||||
//--- calculate the scale maximum
|
||||
m_max=Mod(m_max,m_step)==0.0 ? m_max : m_max+m_step-Mod(m_max,m_step);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expands the boundaries to the left and right. |
|
||||
//+------------------------------------------------------------------+
|
||||
void CAxis::ExtensionBoundaries(void)
|
||||
{
|
||||
double range=m_max-m_min;
|
||||
//--- do not let the grace value extend the axis below zero when all the values were positive
|
||||
if(m_min<0 || m_min-m_min_grace*range>=0.0)
|
||||
m_min=m_min-m_min_grace*range;
|
||||
//--- do not let the grace value extend the axis above zero when all the values were negative
|
||||
if(m_max>0 || m_max+m_max_grace*range<=0.0)
|
||||
m_max=m_max+m_max_grace*range;
|
||||
//--- calculate new min and max values if they equal
|
||||
if(m_max==m_min)
|
||||
{
|
||||
if(MathAbs(m_max)>1e-100)
|
||||
{
|
||||
m_max *= (m_min < 0 ? 0.95 : 1.05 );
|
||||
m_min *= (m_min < 0 ? 1.05 : 0.95 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_max = 1.0;
|
||||
m_min = -1.0;
|
||||
}
|
||||
}
|
||||
//---
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Calculate a m_step size based on a data range. |
|
||||
//+------------------------------------------------------------------+
|
||||
double CAxis::CalcStepSize(const double range,const double steps)
|
||||
{
|
||||
//--- calculate an initial guess at m_step size
|
||||
double temp=range/steps;
|
||||
//--- get the magnitude of the m_step size
|
||||
double mag=MathFloor(MathLog10(temp));
|
||||
double magPow=MathPow(10.0,mag);
|
||||
//--- calculate most significant digit of the new m_step size
|
||||
double magMsd=NormalizeDouble(temp/magPow+.5,0);
|
||||
//--- promote the MSD to either 1, 2, or 5
|
||||
if(magMsd>5.0)
|
||||
magMsd=10.0;
|
||||
else
|
||||
if(magMsd>2.0)
|
||||
magMsd=5.0;
|
||||
else
|
||||
if(magMsd>1.0)
|
||||
magMsd=2.0;
|
||||
//--- return step
|
||||
return(magMsd * magPow);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Calculate the modulus (remainder) in a safe manner so that divide|
|
||||
//| by zero errors are avoided |
|
||||
//+------------------------------------------------------------------+
|
||||
double CAxis::Mod(const double x,const double y)
|
||||
{
|
||||
//--- check
|
||||
if(y==0)
|
||||
return(0);
|
||||
//--- calculate modulus
|
||||
return (x>0)? MathMod(x,y): MathMod(x,y)+y;
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Calculate a m_step size based on a data range, limited to a max |
|
||||
//| number of steps. |
|
||||
//+------------------------------------------------------------------+
|
||||
double CAxis::CalcBoundedStepSize(const double range,const double max_steps)
|
||||
{
|
||||
//--- calculate an initial guess at m_step size
|
||||
double temp=range/max_steps;
|
||||
//--- get the magnitude of the m_step size
|
||||
double mag=MathFloor(MathLog10(temp));
|
||||
double magPow=MathPow((double) 10.0,mag);
|
||||
//--- calculate most significant digit of the new m_step size
|
||||
double magMsd=MathCeil(temp/magPow);
|
||||
//--- promote the MSD to either 1, 2, or 5
|
||||
if(magMsd>5.0)
|
||||
magMsd=10.0;
|
||||
else
|
||||
if(magMsd>2.0)
|
||||
magMsd=5.0;
|
||||
else
|
||||
if(magMsd>1.0)
|
||||
magMsd=2.0;
|
||||
//--- return step
|
||||
return(magMsd * magPow);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,74 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| ColorGenerator.mqh |
|
||||
//| Copyright 2000-2026, MetaQuotes Ltd. |
|
||||
//| www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CColorGenerator |
|
||||
//| Usage: class to generate the default colors |
|
||||
//+------------------------------------------------------------------+
|
||||
class CColorGenerator
|
||||
{
|
||||
private:
|
||||
int m_index;
|
||||
bool m_generate;
|
||||
uint m_current_palette[20];
|
||||
const static uint s_default_palette[20];
|
||||
|
||||
public:
|
||||
CColorGenerator(void);
|
||||
~CColorGenerator(void);
|
||||
//--- gets the next color
|
||||
uint Next(void);
|
||||
//--- reset generator
|
||||
void Reset(void);
|
||||
};
|
||||
const uint CColorGenerator::s_default_palette[20]=
|
||||
{
|
||||
0x3366CC,0xDC3912,0xFF9900,0x109618,0x990099,
|
||||
0x3B3EAC,0x0099C6,0xDD4477,0x66AA00,0xB82E2E,
|
||||
0x316395,0x994499,0x22AA99,0xAAAA11,0x6633CC,
|
||||
0xE67300,0x8B0707,0x329262,0x5574A6,0x3B3EAC
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CColorGenerator::CColorGenerator(void): m_index(0),
|
||||
m_generate(false)
|
||||
{
|
||||
ArrayCopy(m_current_palette,s_default_palette);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CColorGenerator::~CColorGenerator(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Gets or generates the following color from the palette |
|
||||
//+------------------------------------------------------------------+
|
||||
uint CColorGenerator::Next(void)
|
||||
{
|
||||
//--- check the array out of range
|
||||
if(m_index==20)
|
||||
{
|
||||
m_index=0;
|
||||
if(!m_generate)
|
||||
m_generate=true;
|
||||
}
|
||||
//--- check the default palette is over
|
||||
if(m_generate)
|
||||
m_current_palette[m_index]=(m_index==19 ? (m_current_palette[m_index]^m_current_palette[0]):(m_current_palette[m_index]^m_current_palette[m_index+1]));
|
||||
//--- return next color
|
||||
return(m_current_palette[m_index++]);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Resets all the new colors, set the index to 0 |
|
||||
//+------------------------------------------------------------------+
|
||||
void CColorGenerator::Reset(void)
|
||||
{
|
||||
m_index=0;
|
||||
m_generate=false;
|
||||
ArrayCopy(m_current_palette,s_default_palette);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,700 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| Curve.mqh |
|
||||
//| Copyright 2000-2026, MetaQuotes Ltd. |
|
||||
//| www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#include <Object.mqh>
|
||||
#include <Canvas\Canvas.mqh>
|
||||
//--- forward declaration
|
||||
class CGraphic;
|
||||
//--- fucntion for represent custom plot method
|
||||
typedef void(*PlotFucntion)(double &x[],double &y[],int size,CGraphic *graphic,CCanvas *canvas,void *cbdata);
|
||||
//--- function for represent curve
|
||||
typedef double(*CurveFunction)(double);
|
||||
//--- drawing type
|
||||
enum ENUM_CURVE_TYPE
|
||||
{
|
||||
CURVE_POINTS,
|
||||
CURVE_LINES,
|
||||
CURVE_POINTS_AND_LINES,
|
||||
CURVE_STEPS,
|
||||
CURVE_HISTOGRAM,
|
||||
CURVE_CUSTOM,
|
||||
CURVE_NONE
|
||||
};
|
||||
//--- type for the various point shapes that are available
|
||||
enum ENUM_POINT_TYPE
|
||||
{
|
||||
POINT_CIRCLE,
|
||||
POINT_SQUARE,
|
||||
POINT_DIAMOND,
|
||||
POINT_TRIANGLE,
|
||||
POINT_TRIANGLE_DOWN,
|
||||
POINT_X_CROSS,
|
||||
POINT_PLUS,
|
||||
POINT_STAR,
|
||||
POINT_HORIZONTAL_DASH,
|
||||
POINT_VERTICAL_DASH
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Structure CPoint2D |
|
||||
//| Usage: 2d point on graphic in Cartesian coordinates |
|
||||
//+------------------------------------------------------------------+
|
||||
struct CPoint2D
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Class CCurve |
|
||||
//| Usage: class to represent the one-dimensional curve |
|
||||
//+------------------------------------------------------------------+
|
||||
class CCurve : public CObject
|
||||
{
|
||||
private:
|
||||
uint m_clr;
|
||||
double m_x[];
|
||||
double m_y[];
|
||||
double m_xmin;
|
||||
double m_xmax;
|
||||
double m_ymin;
|
||||
double m_ymax;
|
||||
int m_size;
|
||||
ENUM_CURVE_TYPE m_type;
|
||||
string m_name;
|
||||
//--- lines
|
||||
ENUM_LINE_STYLE m_lines_style;
|
||||
ENUM_LINE_END m_lines_end_style;
|
||||
int m_lines_width;
|
||||
bool m_lines_smooth;
|
||||
double m_lines_tension;
|
||||
double m_lines_step;
|
||||
//--- points
|
||||
int m_points_size;
|
||||
ENUM_POINT_TYPE m_points_type;
|
||||
bool m_points_fill;
|
||||
uint m_points_clr;
|
||||
//--- steps
|
||||
int m_steps_dimension;
|
||||
//--- histogram
|
||||
int m_hisogram_width;
|
||||
//--- custom
|
||||
PlotFucntion m_custom_plot_func;
|
||||
void *m_custom_plot_cbdata;
|
||||
//--- general property
|
||||
bool m_visible;
|
||||
//--- trend line property
|
||||
uint m_trend_clr;
|
||||
bool m_trend_visible;
|
||||
|
||||
protected:
|
||||
bool m_trend_calc;
|
||||
double m_trend_coeff[];
|
||||
|
||||
public:
|
||||
CCurve(const double &y[],const uint clr,ENUM_CURVE_TYPE type,const string name);
|
||||
CCurve(const double &x[],const double &y[],const uint clr,ENUM_CURVE_TYPE type,const string name);
|
||||
CCurve(const CPoint2D &points[],const uint clr,ENUM_CURVE_TYPE type,const string name);
|
||||
CCurve(CurveFunction function,const double from,const double to,const double step,const uint clr,ENUM_CURVE_TYPE type,const string name);
|
||||
~CCurve(void);
|
||||
//--- gets the general properties
|
||||
void GetX(double &x[]) const { ArrayCopy(x,m_x); }
|
||||
void GetY(double &y[]) const { ArrayCopy(y,m_y); }
|
||||
double XMax(void) const { return(m_xmax); }
|
||||
double XMin(void) const { return(m_xmin); }
|
||||
double YMax(void) const { return(m_ymax); }
|
||||
double YMin(void) const { return(m_ymin); }
|
||||
int Size(void) const { return(m_size); }
|
||||
//--- update
|
||||
void Update(const double &y[]);
|
||||
void Update(const double &x[],const double &y[]);
|
||||
void Update(const CPoint2D &points[]);
|
||||
void Update(CurveFunction function,const double from,const double to,const double step);
|
||||
//--- gets or sets general options
|
||||
uint Color(void) const { return(m_clr); }
|
||||
int Type(void) const { return(m_type); }
|
||||
string Name(void) const { return(m_name); }
|
||||
bool Visible(void) const { return(m_visible); }
|
||||
void Color(const uint clr) { m_clr=clr; }
|
||||
void Type(const int type) { m_type=(ENUM_CURVE_TYPE)type; }
|
||||
void Name(const string name) { m_name=name; }
|
||||
void Visible(const bool visible) { m_visible=visible; }
|
||||
//--- gets or sets the lines properties
|
||||
ENUM_LINE_STYLE LinesStyle(void) const { return(m_lines_style); }
|
||||
ENUM_LINE_END LinesEndStyle(void) const { return(m_lines_end_style); }
|
||||
int LinesWidth(void) const { return(m_lines_width); }
|
||||
bool LinesSmooth(void) const { return(m_lines_smooth); }
|
||||
double LinesSmoothTension(void) const { return(m_lines_tension); }
|
||||
double LinesSmoothStep(void) const { return(m_lines_step); }
|
||||
void LinesStyle(ENUM_LINE_STYLE style) { m_lines_style=style; }
|
||||
void LinesEndStyle(ENUM_LINE_END end_style) { m_lines_end_style=end_style; }
|
||||
void LinesWidth(const int width) { m_lines_width=width; }
|
||||
void LinesSmooth(const bool smooth) { m_lines_smooth=smooth; }
|
||||
void LinesSmoothTension(const double tension) { m_lines_tension=tension; }
|
||||
void LinesSmoothStep(const double step) { m_lines_step=step; }
|
||||
//--- gets or sets the points properties
|
||||
int PointsSize(void) const { return(m_points_size); }
|
||||
ENUM_POINT_TYPE PointsType(void) const { return(m_points_type); }
|
||||
bool PointsFill(void) const { return(m_points_fill); }
|
||||
uint PointsColor(void) const { return(m_points_clr); }
|
||||
void PointsSize(const int size) { m_points_size=size; }
|
||||
void PointsType(ENUM_POINT_TYPE type) { m_points_type=type; }
|
||||
void PointsFill(const bool fill) { m_points_fill=fill; }
|
||||
void PointsColor(const uint clr) { m_points_clr=clr; }
|
||||
//--- gets or sets the steps properties
|
||||
int StepsDimension(void) const { return(m_steps_dimension); }
|
||||
void StepsDimension(const int dimension) { m_steps_dimension=dimension; }
|
||||
//--- gets or sets the histogram properties
|
||||
int HistogramWidth(void) const { return(m_hisogram_width); }
|
||||
void HistogramWidth(const int width) { m_hisogram_width=width; }
|
||||
//--- gets or sets the custom properties
|
||||
PlotFucntion CustomPlotFunction(void) const { return(m_custom_plot_func); }
|
||||
void *CustomPlotCBData(void) const { return(m_custom_plot_cbdata); }
|
||||
void CustomPlotFunction(PlotFucntion func) { m_custom_plot_func=func; }
|
||||
void CustomPlotCBData(void *cbdata) { m_custom_plot_cbdata=cbdata; }
|
||||
//--- gets or sets the trend line properties
|
||||
bool TrendLineVisible(void) const { return(m_trend_visible); }
|
||||
uint TrendLineColor(void) const { return(m_trend_clr); }
|
||||
void TrendLineVisible(const bool visible) { m_trend_visible=visible; }
|
||||
void TrendLineColor(const uint clr) { m_trend_clr=clr; }
|
||||
void TrendLineCoefficients(double &coefficients[]);
|
||||
|
||||
protected:
|
||||
virtual void CalculateCoefficients(void);
|
||||
};
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CCurve::CCurve(const double &y[],const uint clr,ENUM_CURVE_TYPE type,const string name)
|
||||
: m_name(name),
|
||||
m_clr(clr),
|
||||
m_type(type),
|
||||
m_visible(false),
|
||||
m_lines_style(STYLE_SOLID),
|
||||
m_lines_end_style(LINE_END_ROUND),
|
||||
m_lines_width(1),
|
||||
m_lines_smooth(false),
|
||||
m_lines_tension(0.5),
|
||||
m_lines_step(1.0),
|
||||
m_points_size(6),
|
||||
m_points_type(POINT_CIRCLE),
|
||||
m_points_fill(false),
|
||||
m_points_clr(clr),
|
||||
m_steps_dimension(0),
|
||||
m_hisogram_width(1),
|
||||
m_custom_plot_func(NULL),
|
||||
m_custom_plot_cbdata(NULL),
|
||||
m_trend_visible(false),
|
||||
m_trend_clr(clr),
|
||||
m_trend_calc(false)
|
||||
{
|
||||
//--- keep y array
|
||||
m_size=ArraySize(y);
|
||||
ArrayResize(m_x,m_size);
|
||||
ArrayCopy(m_y,y);
|
||||
m_xmax = m_size-1;
|
||||
m_xmin = 0.0;
|
||||
m_ymax = 0.0;
|
||||
m_ymin = 0.0;
|
||||
bool yvalid=false;
|
||||
//--- find min and max values
|
||||
for(int i=0; i<m_size; i++)
|
||||
{
|
||||
m_x[i]=i;
|
||||
if(MathIsValidNumber(m_y[i]))
|
||||
{
|
||||
if(!yvalid)
|
||||
{
|
||||
m_ymax=m_y[i];
|
||||
m_ymin= m_y[i];
|
||||
yvalid=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//--- find max and min of y
|
||||
if(m_ymax<y[i])
|
||||
m_ymax=y[i];
|
||||
else
|
||||
if(m_ymin>y[i])
|
||||
m_ymin=y[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
//---
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CCurve::CCurve(const double &x[],const double &y[],const uint clr,ENUM_CURVE_TYPE type,const string name)
|
||||
: m_name(name),
|
||||
m_clr(clr),
|
||||
m_type(type),
|
||||
m_visible(false),
|
||||
m_lines_style(STYLE_SOLID),
|
||||
m_lines_end_style(LINE_END_ROUND),
|
||||
m_lines_width(1),
|
||||
m_lines_smooth(false),
|
||||
m_lines_tension(0.5),
|
||||
m_lines_step(1.0),
|
||||
m_points_size(6),
|
||||
m_points_type(POINT_CIRCLE),
|
||||
m_points_fill(false),
|
||||
m_points_clr(clr),
|
||||
m_steps_dimension(0),
|
||||
m_hisogram_width(1),
|
||||
m_custom_plot_func(NULL),
|
||||
m_custom_plot_cbdata(NULL),
|
||||
m_trend_visible(false),
|
||||
m_trend_clr(clr),
|
||||
m_trend_calc(false)
|
||||
{
|
||||
//--- keep x and y array
|
||||
ArrayCopy(m_x,x);
|
||||
ArrayCopy(m_y,y);
|
||||
m_size = ArraySize(x);
|
||||
m_xmax = 0.0;
|
||||
m_xmin = 0.0;
|
||||
m_ymax = 0.0;
|
||||
m_ymin = 0.0;
|
||||
bool yvalid=false;
|
||||
bool xvalid=false;
|
||||
//--- find min and max values
|
||||
for(int i=0; i<m_size; i++)
|
||||
{
|
||||
if(MathIsValidNumber(m_x[i]))
|
||||
{
|
||||
if(!xvalid)
|
||||
{
|
||||
m_xmax = x[i];
|
||||
m_xmin = x[i];
|
||||
xvalid=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//--- find max and min of x
|
||||
if(m_xmax<x[i])
|
||||
m_xmax=x[i];
|
||||
else
|
||||
if(m_xmin>x[i])
|
||||
m_xmin=x[i];
|
||||
}
|
||||
}
|
||||
if(MathIsValidNumber(m_y[i]))
|
||||
{
|
||||
if(!yvalid)
|
||||
{
|
||||
m_ymax = y[i];
|
||||
m_ymin = y[i];
|
||||
yvalid=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//--- find max and min of y
|
||||
if(m_ymax<y[i])
|
||||
m_ymax=y[i];
|
||||
else
|
||||
if(m_ymin>y[i])
|
||||
m_ymin=y[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
//---
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CCurve::CCurve(const CPoint2D &points[],const uint clr,ENUM_CURVE_TYPE type,const string name)
|
||||
: m_name(name),
|
||||
m_clr(clr),
|
||||
m_type(type),
|
||||
m_visible(false),
|
||||
m_lines_style(STYLE_SOLID),
|
||||
m_lines_end_style(LINE_END_ROUND),
|
||||
m_lines_width(1),
|
||||
m_lines_smooth(false),
|
||||
m_lines_tension(0.5),
|
||||
m_lines_step(1.0),
|
||||
m_points_size(6),
|
||||
m_points_type(POINT_CIRCLE),
|
||||
m_points_fill(false),
|
||||
m_points_clr(clr),
|
||||
m_steps_dimension(0),
|
||||
m_hisogram_width(1),
|
||||
m_custom_plot_func(NULL),
|
||||
m_custom_plot_cbdata(NULL),
|
||||
m_trend_visible(false),
|
||||
m_trend_clr(clr),
|
||||
m_trend_calc(false)
|
||||
{
|
||||
//--- preliminary calculation
|
||||
m_size=ArraySize(points);
|
||||
ArrayResize(m_x,m_size);
|
||||
ArrayResize(m_y,m_size);
|
||||
m_xmax = 0.0;
|
||||
m_xmin = 0.0;
|
||||
m_ymax = 0.0;
|
||||
m_ymin = 0.0;
|
||||
bool xvalid=false;
|
||||
bool yvalid=false;
|
||||
//--- keep x and y array
|
||||
for(int i=0; i<m_size; i++)
|
||||
{
|
||||
m_x[i] = points[i].x;
|
||||
m_y[i] = points[i].y;
|
||||
if(MathIsValidNumber(m_x[i]))
|
||||
{
|
||||
if(!xvalid)
|
||||
{
|
||||
m_xmax = m_x[i];
|
||||
m_xmin = m_x[i];
|
||||
xvalid=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//--- find max and min of x
|
||||
if(m_xmax<m_x[i])
|
||||
m_xmax=m_x[i];
|
||||
else
|
||||
if(m_xmin>m_x[i])
|
||||
m_xmin=m_x[i];
|
||||
}
|
||||
}
|
||||
if(MathIsValidNumber(m_y[i]))
|
||||
{
|
||||
if(!yvalid)
|
||||
{
|
||||
m_ymax = m_y[i];
|
||||
m_ymin = m_y[i];
|
||||
yvalid=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//--- find max and min of y
|
||||
if(m_ymax<m_y[i])
|
||||
m_ymax=m_y[i];
|
||||
else
|
||||
if(m_ymin>m_y[i])
|
||||
m_ymin=m_y[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
//---
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Constructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CCurve::CCurve(CurveFunction function,const double from,const double to,const double step,const uint clr,ENUM_CURVE_TYPE type,const string name)
|
||||
: m_name(name),
|
||||
m_clr(clr),
|
||||
m_type(type),
|
||||
m_visible(false),
|
||||
m_lines_style(STYLE_SOLID),
|
||||
m_lines_end_style(LINE_END_ROUND),
|
||||
m_lines_width(1),
|
||||
m_lines_smooth(false),
|
||||
m_lines_tension(0.5),
|
||||
m_lines_step(1.0),
|
||||
m_points_size(6),
|
||||
m_points_type(POINT_CIRCLE),
|
||||
m_points_fill(false),
|
||||
m_points_clr(clr),
|
||||
m_steps_dimension(0),
|
||||
m_hisogram_width(1),
|
||||
m_custom_plot_func(NULL),
|
||||
m_custom_plot_cbdata(NULL),
|
||||
m_trend_visible(false),
|
||||
m_trend_clr(clr),
|
||||
m_trend_calc(false)
|
||||
{
|
||||
//--- preliminary calculation
|
||||
m_size=(int)((to-from)/step)+1;
|
||||
ArrayResize(m_x,m_size);
|
||||
ArrayResize(m_y,m_size);
|
||||
m_xmax = to;
|
||||
m_xmin = from;
|
||||
m_ymax = 0.0;
|
||||
m_ymin = 0.0;
|
||||
bool yvalid=false;
|
||||
//--- keep x and y array
|
||||
for(int i=0; i<m_size; i++)
|
||||
{
|
||||
m_x[i]=from+(i*step);
|
||||
m_y[i]=function(m_x[i]);
|
||||
if(MathIsValidNumber(m_y[i]))
|
||||
{
|
||||
if(!yvalid)
|
||||
{
|
||||
m_ymax=m_y[i];
|
||||
m_ymin=m_y[i];
|
||||
yvalid=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//--- find max and min of y
|
||||
if(m_ymax<m_y[i])
|
||||
m_ymax=m_y[i];
|
||||
else if(m_ymin>m_y[i])
|
||||
m_ymin=m_y[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
//---
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Destructor |
|
||||
//+------------------------------------------------------------------+
|
||||
CCurve::~CCurve(void)
|
||||
{
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Update x and y coordinates of curve |
|
||||
//+------------------------------------------------------------------+
|
||||
void CCurve::Update(const double &y[])
|
||||
{
|
||||
m_trend_calc=false;
|
||||
ArrayFree(m_y);
|
||||
int size=ArraySize(y);
|
||||
//--- keep y array
|
||||
if(m_size!=size)
|
||||
{
|
||||
m_size=size;
|
||||
ArrayResize(m_x,m_size);
|
||||
}
|
||||
ArrayCopy(m_y,y);
|
||||
m_xmax = m_size-1;
|
||||
m_xmin = 0.0;
|
||||
m_ymax = 0.0;
|
||||
m_ymin = 0.0;
|
||||
bool yvalid=false;
|
||||
//--- find min and max values
|
||||
for(int i=0; i<m_size; i++)
|
||||
{
|
||||
m_x[i]=i;
|
||||
if(MathIsValidNumber(m_y[i]))
|
||||
{
|
||||
if(!yvalid)
|
||||
{
|
||||
m_ymax=m_y[i];
|
||||
m_ymin= m_y[i];
|
||||
yvalid=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//--- find max and min of y
|
||||
if(m_ymax<y[i])
|
||||
m_ymax=y[i];
|
||||
else
|
||||
if(m_ymin>y[i])
|
||||
m_ymin=y[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
//---
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Update x and y coordinates of curve |
|
||||
//+------------------------------------------------------------------+
|
||||
void CCurve::Update(const double &x[],const double &y[])
|
||||
{
|
||||
m_trend_calc=false;
|
||||
ArrayFree(m_x);
|
||||
ArrayFree(m_y);
|
||||
//--- keep x and y array
|
||||
ArrayCopy(m_x,x);
|
||||
ArrayCopy(m_y,y);
|
||||
m_size = ArraySize(x);
|
||||
m_xmax = 0.0;
|
||||
m_xmin = 0.0;
|
||||
m_ymax = 0.0;
|
||||
m_ymin = 0.0;
|
||||
bool yvalid=false;
|
||||
bool xvalid=false;
|
||||
//--- find min and max values
|
||||
for(int i=0; i<m_size; i++)
|
||||
{
|
||||
if(MathIsValidNumber(m_x[i]))
|
||||
{
|
||||
if(!xvalid)
|
||||
{
|
||||
m_xmax = x[i];
|
||||
m_xmin = x[i];
|
||||
xvalid=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//--- find max and min of x
|
||||
if(m_xmax<x[i])
|
||||
m_xmax=x[i];
|
||||
else
|
||||
if(m_xmin>x[i])
|
||||
m_xmin=x[i];
|
||||
}
|
||||
}
|
||||
if(MathIsValidNumber(m_y[i]))
|
||||
{
|
||||
if(!yvalid)
|
||||
{
|
||||
m_ymax = y[i];
|
||||
m_ymin = y[i];
|
||||
yvalid=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//--- find max and min of y
|
||||
if(m_ymax<y[i])
|
||||
m_ymax=y[i];
|
||||
else
|
||||
if(m_ymin>y[i])
|
||||
m_ymin=y[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
//---
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Update x and y coordinates of curve |
|
||||
//+------------------------------------------------------------------+
|
||||
void CCurve::Update(const CPoint2D &points[])
|
||||
{
|
||||
m_trend_calc=false;
|
||||
int size=ArraySize(points);
|
||||
//--- preliminary calculation
|
||||
if(size!=m_size)
|
||||
{
|
||||
m_size=size;
|
||||
ArrayResize(m_x,m_size);
|
||||
ArrayResize(m_y,m_size);
|
||||
}
|
||||
m_xmax = 0.0;
|
||||
m_xmin = 0.0;
|
||||
m_ymax = 0.0;
|
||||
m_ymin = 0.0;
|
||||
bool xvalid=false;
|
||||
bool yvalid=false;
|
||||
//--- keep x and y array
|
||||
for(int i=0; i<m_size; i++)
|
||||
{
|
||||
m_x[i] = points[i].x;
|
||||
m_y[i] = points[i].y;
|
||||
if(MathIsValidNumber(m_x[i]))
|
||||
{
|
||||
if(!xvalid)
|
||||
{
|
||||
m_xmax = m_x[i];
|
||||
m_xmin = m_x[i];
|
||||
xvalid=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//--- find max and min of x
|
||||
if(m_xmax<m_x[i])
|
||||
m_xmax=m_x[i];
|
||||
else
|
||||
if(m_xmin>m_x[i])
|
||||
m_xmin=m_x[i];
|
||||
}
|
||||
}
|
||||
if(MathIsValidNumber(m_y[i]))
|
||||
{
|
||||
if(!yvalid)
|
||||
{
|
||||
m_ymax = m_y[i];
|
||||
m_ymin = m_y[i];
|
||||
yvalid=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//--- find max and min of y
|
||||
if(m_ymax<m_y[i])
|
||||
m_ymax=m_y[i];
|
||||
else
|
||||
if(m_ymin>m_y[i])
|
||||
m_ymin=m_y[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
//---
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Update x and y coordinates of curve |
|
||||
//+------------------------------------------------------------------+
|
||||
void CCurve::Update(CurveFunction function,const double from,const double to,const double step)
|
||||
{
|
||||
m_trend_calc=false;
|
||||
int size=(int)((to-from)/step)+1;
|
||||
//--- preliminary calculation
|
||||
if(size!=m_size)
|
||||
{
|
||||
m_size=size;
|
||||
ArrayResize(m_x,m_size);
|
||||
ArrayResize(m_y,m_size);
|
||||
}
|
||||
m_xmax = to;
|
||||
m_xmin = from;
|
||||
m_ymax = 0.0;
|
||||
m_ymin = 0.0;
|
||||
bool yvalid=false;
|
||||
//--- keep x and y array
|
||||
for(int i=0; i<m_size; i++)
|
||||
{
|
||||
m_x[i]=from+(i*step);
|
||||
m_y[i]=function(m_x[i]);
|
||||
if(MathIsValidNumber(m_y[i]))
|
||||
{
|
||||
if(!yvalid)
|
||||
{
|
||||
m_ymax=m_y[i];
|
||||
m_ymin=m_y[i];
|
||||
yvalid=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//--- find max and min of y
|
||||
if(m_ymax<m_y[i])
|
||||
m_ymax=m_y[i];
|
||||
else if(m_ymin>m_y[i])
|
||||
m_ymin=m_y[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
//---
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Gets the coefficients for trend line |
|
||||
//+------------------------------------------------------------------+
|
||||
void CCurve::TrendLineCoefficients(double &coefficients[])
|
||||
{
|
||||
if(!m_trend_calc)
|
||||
{
|
||||
CalculateCoefficients();
|
||||
m_trend_calc=true;
|
||||
}
|
||||
ArrayCopy(coefficients,m_trend_coeff);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Calculate coefficients |
|
||||
//+------------------------------------------------------------------+
|
||||
void CCurve::CalculateCoefficients(void)
|
||||
{
|
||||
//--- simple linear resgression
|
||||
ArrayResize(m_trend_coeff,2);
|
||||
double xmean=0.0;
|
||||
double ymean=0.0;
|
||||
double sum_xy=0.0;
|
||||
double sum_xx=0.0;
|
||||
//--- primary calculate
|
||||
for(int i=0; i<m_size; i++)
|
||||
{
|
||||
xmean+=m_x[i];
|
||||
ymean+=m_y[i];
|
||||
sum_xy+=m_x[i]*m_y[i];
|
||||
sum_xx+=m_x[i]*m_x[i];
|
||||
}
|
||||
xmean/=m_size;
|
||||
ymean/=m_size;
|
||||
//--- calculate intercept
|
||||
m_trend_coeff[0]=(sum_xy -(m_size*xmean*ymean))/(sum_xx -(m_size*xmean*xmean));
|
||||
//--- calculate slope
|
||||
m_trend_coeff[1]=ymean-m_trend_coeff[0]*xmean;
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
Binary file not shown.
Reference in New Issue
Block a user