1 Star 0 Fork 0

qin_yi/EA31337-classes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
DrawIndicator.mqh 3.00 KB
一键复制 编辑 原始数据 按行查看 历史
kenorb 提交于 2020-04-25 19:07 . Improves code formatting
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2020, 31337 Investments Ltd |
//| https://github.com/EA31337 |
//+------------------------------------------------------------------+
/*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* @file
* Group of functions intended for working with graphic objects relating to any specified chart.
*/
// Ignore processing of this file if already included.
#ifndef DRAW_INDICATOR_MQH
#define DRAW_INDICATOR_MQH
// Includes.
#include "DictObject.mqh"
#include "Draw.mqh"
#include "Indicator.mqh"
#include "Object.mqh"
// Forward declaration.
class Indicator;
class DrawPoint {
public:
datetime time;
double value;
// Operator overloading methods.
void operator=(const DrawPoint& r) {
time = r.time;
value = r.value;
}
// Special methods.
DrawPoint(const DrawPoint& r) : time(r.time), value(r.value) {}
DrawPoint(datetime _time = NULL, double _value = 0) : time(_time), value(_value) {}
};
class DrawIndicator {
protected:
color color_line;
Draw* draw;
Indicator* indi;
public:
// Object variables.
DictObject<string, DrawPoint> last_points;
/* Special methods */
/**
* Class constructor.
*/
DrawIndicator(Indicator* _indi) : indi(_indi) {
color_line = Object::IsValid(_indi) ? _indi.GetParams().indi_color : clrRed;
draw = new Draw();
}
/**
* Class deconstructor.
*/
~DrawIndicator() {
if (draw != NULL) {
delete draw;
}
/* @fixme
for (DictObjectIterator<string, DrawPoint> iter = indis.Begin(); iter.IsValid(); ++iter) {
delete iter.Value();
}
*/
}
/* Setters */
/* Class methods */
/**
* Sets color of line.
*/
void SetColorLine(color _clr) { color_line = _clr; }
/**
* Draw line from the last point.
*/
void DrawLineTo(string name, datetime time, double value, int window = WINDOW_MAIN) {
if (!last_points.KeyExists(name)) {
last_points.Set(name, DrawPoint(time, value));
} else {
DrawPoint* last_point = last_points.GetByKey(name);
draw.TLine(name + "_" + IntegerToString(time), last_point.value, value, last_point.time, time, color_line, false,
window);
last_point.time = time;
last_point.value = value;
}
}
};
#endif // DRAW_INDICATOR_MQH
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/qinyi.git.org/EA31337-classes.git
git@gitee.com:qinyi.git.org/EA31337-classes.git
qinyi.git.org
EA31337-classes
EA31337-classes
master

搜索帮助