Type/to search

获取周K线

Extent-API
0
Follow
2
Followers

把日K线组合为周K线,默认一周开始于周日(可调)。

使用方法:
$.GetRecordsWeek(exchange)

Source
JavaScript
$.GetRecordsWeek = function(exchange) {
    var rec1 = exchange.GetRecords(PERIOD_D1);
    if (!rec1) return null;
    if (rec1.length === 0) return [];
    var recN = [];
    var tmp = {
        Time: rec1[0].Time,
        Open: rec1[0].Open,
        High: rec1[0].High,
        Low: rec1[0].Low,
        Close: rec1[0].Close,
        Volume: rec1[0].Volume
Strategy parameters
Strategy parameters
一周开始于
Comment
All comments (3)

    大神,如果要4小时K线的话,怎么改?

    9 years ago

    【第2行改成】
    var rec1 = exchange.GetRecords(PERIOD_H1);

    【第15行改成】
    if (Math.floor((rec1[i].Time / 3600000 / 4) + 1e-6) > Math.floor((rec1[i-1].Time / 3600000 / 4) + 1e-6)) {

    9 years ago

    谢谢大神

    10 years ago
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)