1 Star 0 Fork 0

qin_yi/EA31337-classes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Chart.struct.h 2.92 KB
一键复制 编辑 原始数据 按行查看 历史
//+------------------------------------------------------------------+
//| 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
* Includes Chart's structs.
*/
// Forward class declaration.
class JsonSerializer;
// Includes.
#include "JsonNode.enum.h"
// Struct for storing OHLC values.
struct OHLC {
datetime time;
double open, high, low, close;
// Struct constructor.
OHLC() : open(0), high(0), low(0), close(0), time(0){};
OHLC(double _open, double _high, double _low, double _close, datetime _time = 0)
: time(_time), open(_open), high(_high), low(_low), close(_close) {
if (_time == 0) {
_time = TimeCurrent();
}
}
// Struct methods.
// Serializers.
JsonNodeType Serialize(JsonSerializer& s) {
// s.Pass(this, "time", TimeToString(time));
s.Pass(this, "open", open);
s.Pass(this, "high", high);
s.Pass(this, "low", low);
s.Pass(this, "close", close);
return JsonNodeObject;
}
string ToCSV() { return StringFormat("%d,%g,%g,%g,%g", time, open, high, low, close); }
};
// Defines struct to store symbol data.
struct ChartEntry {
OHLC ohlc;
ChartEntry() {}
ChartEntry(const OHLC& _ohlc) { ohlc = _ohlc; }
// Struct getters
OHLC GetOHLC() { return ohlc; }
// Serializers.
JsonNodeType Serialize(JsonSerializer& s) {
string _ohlc = JSON::Stringify(ohlc);
s.Pass(this, "ohlc", _ohlc);
return JsonNodeObject;
}
string ToCSV() { return StringFormat("%s", ohlc.ToCSV()); }
};
// Defines struct for chart parameters.
struct ChartParams {
ENUM_TIMEFRAMES tf;
ENUM_TIMEFRAMES_INDEX tfi;
ENUM_PP_TYPE pp_type;
// Constructor.
void ChartParams(ENUM_TIMEFRAMES _tf = PERIOD_CURRENT) : tf(_tf), tfi(Chart::TfToIndex(_tf)), pp_type(PP_CLASSIC){};
void ChartParams(ENUM_TIMEFRAMES_INDEX _tfi) : tfi(_tfi), tf(Chart::IndexToTf(_tfi)), pp_type(PP_CLASSIC){};
void SetPP(ENUM_PP_TYPE _pp) { pp_type = _pp; }
void SetTf(ENUM_TIMEFRAMES _tf) {
tf = _tf;
tfi = Chart::TfToIndex(_tf);
};
};
// Struct for pivot points.
struct PivotPoints {
double pp, s1, s2, s3, s4, r1, r2, r3, r4;
};
马建仓 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

搜索帮助