Type/to search
0
Follow
0
Followers
Tìm kiếm bánh xe js của chỉ báo William
Help
Created 2021-10-23 08:02:58  
 3
 1306

Ví dụ, các thư viện chính sách cộng đồng không tìm thấy bánh xe xử lý js tương tự như chỉ số William.

Related Recommendations
Comment
All comments (3)

    function arrayMax(array) {
    return Math.max.apply(
    Math,
    array.filter(function (n) {
    return !isNaN(n);
    })
    );
    }
    function arrayMin(array) {
    return Math.min.apply(
    Math,
    array.filter(function (n) {
    return !isNaN(n);
    })
    );
    }
    function WILLR(highs, lows, closes, lookback) {
    var willr = [],
    highest_high,
    lowest_low,
    curr_close,
    i;
    // computing only if highs and lows arrays are of equal length
    if (highs.length == lows.length && highs.length >= lookback) {
    /*
    * Willams %R exists only for the values which have atleast "lookback" values
    * so we iterate till ((length )-lookback)to calculate Willams %R
    */
    var limit = highs.length - lookback;
    for (i = limit; i >= 0; i--) {
    highest_high = arrayMax(highs.slice(i, i + lookback));
    lowest_low = arrayMin(lows.slice(i, i + lookback));
    curr_close = closes[i];
    willr[i] = ((highest_high - curr_close) / (highest_high - lowest_low)) * -100;
    }
    }
    return willr;
    }

    function main() {
    var highs = [127.01, 127.62, 126.59, 127.35, 128.17, 128.43, 127.37, 126.42, 126.9, 126.85, 125.65, 125.72, 127.16, 127.72, 127.69, 128.22].reverse(),
    lows = [125.36, 126.16, 124.93, 126.09, 126.82, 126.48, 126.03, 124.83, 126.39, 125.72, 124.56, 124.57, 125.07, 126.86, 126.63, 126.8].reverse(),
    close = [127.29, 127.18, 128.01].reverse();
    var willr = WILLR(highs, lows, close, 14);
    Log(willr);
    }

    5 years ago

    感激,谢谢大大。

    5 years ago

    function main(){
    var records = exchange.GetRecords();
    Log(talib.WILLR(records, 7));
    }

    5 years ago
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)