hero87s

"weekly_monthly_peaks_and_troughs.js"

TADAWUL:4240   FAWAZ ABDULAZIZ ALHOKAIR CO.
// Weekly peak and trough indicator

function weekly_monthly_peaks_and_troughs(close, volume) {
// Calculate the weekly and monthly close prices
var weekly_close = close.resample("W").last();
var monthly_close = close.resample("M").last();

// Initialize the peak and trough arrays
var weekly_peaks = ;
var weekly_troughs = ;
var monthly_peaks = ;
var monthly_troughs = ;

// Loop through the data and find the weekly and monthly peaks and troughs
for (var i = 0; i < weekly_close.length; i++) {
// Find the weekly peak
if (i == 0 || weekly_close > weekly_close) {
weekly_peaks.push(weekly_close);
}

// Find the weekly trough
if (i == 0 || weekly_close < weekly_close) {
weekly_troughs.push(weekly_close);
}

// Find the monthly peak
if (i == 0 || monthly_close > monthly_close) {
monthly_peaks.push(monthly_close);
}

// Find the monthly trough
if (i == 0 || monthly_close < monthly_close) {
monthly_troughs.push(monthly_close);
}
}

// Return the peak and trough arrays
return {
weekly_peaks: weekly_peaks,
weekly_troughs: weekly_troughs,
monthly_peaks: monthly_peaks,
monthly_troughs: monthly_troughs,
};
}
Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.