转换任意K线周期
8
Follow
1363
Followers
示例策略
- 转换基础K线为任意K线周期
- 暂时不支持 秒级别
测试版本,如有BUG ,问题 欢迎留言。
Source
JavaScript
// K线周期合成 扩展为 根据基础K线 合成 为任意周期。
var cloneObj = function(obj) { // 深拷贝 对象函数
var str, newobj = obj.constructor === Array ? [] : {};
if (typeof obj !== 'object') {
return;
} else if (JSON) {
str = JSON.stringify(obj); //系列化对象
newobj = JSON.parse(str); //还原
} else {
for (var i in obj) {
newobj[i] = typeof obj[i] === 'object' ?
cloneObj(obj[i]) : obj[i];Strategy parameters
Related strategies
Comment
All comments (16)
为什么用okex数据回测的时候 K线周期选择1分钟 但是却报错目标 周期‘240000’不是 基础周期 ‘180000’ 的整倍数,无法合成!然而我在回测配置参数的时候选的是一分钟 调用函数Getrecords函数的时候也是用的一分钟 为什么合成的时候会出现这样的报错呢
8 years ago
你可以自己试一下 回测数据选OKEX期货 然后基础K线设置为1分钟 合成为4分钟 就会出现我这样的报错
周期‘240000’不是 基础周期 ‘180000’ 的整倍数,无法合成!
8 years ago
这是我的代码while(true){
records = Call(exchange.GetRecords,PERIOD_M1);
//Log("原始K线数据:长度", records.length, "数据:", records);
records = AssembleRecords(records, Num_UI_NewCycleForMS); // 第一个参数是 基础K线, 第二个参数是 要转换的周期的 毫秒数, 1000 * 60 * 20 就是 转换为 20分钟
// Log("转换后K线数据:长度", records.length, "数据:", records);
$.PlotRecords(records, 'BTC');
// throw "stop"; // ceshi
Sleep(1000);
}
这个是参数设置 
明明设置的是一分钟 但是却提示基础K线周期为3分钟 以前没有这种情况的
8 years ago
- 1

