OPEN-SOURCE SCRIPT

ALMA HẰNG DIỄM @

56
//version=5
indicator("ALMA Đa khung thời gian", overlay=true)

// Hàm ALMA tùy chỉnh
f_alma(src, len, offset, sigma) =>
m = math.floor(offset * (len - 1))
s = len > 1 ? len - 1 : 1
norm = 0.0
sum = 0.0
for i = 0 to len - 1
w = math.exp(-(math.pow(i - m, 2)) / (2 * math.pow(sigma, 2)))
norm := norm + w
sum := sum + src * w
sum / norm

// Tham số người dùng
alma_len_short = input.int(9, title="Chu kỳ ngắn")
alma_len_long = input.int(50, title="Chu kỳ dài")
alma_offset = input.float(0.85, title="Offset")
alma_sigma = input.float(6.0, title="Sigma")

// ALMA hiện tại (khung đang xem)
alma_short = f_alma(close, alma_len_short, alma_offset, alma_sigma)
alma_long = f_alma(close, alma_len_long, alma_offset, alma_sigma)

// ALMA khung D1
alma_d1_short = request.security(syminfo.tickerid, "D", f_alma(close, alma_len_short, alma_offset, alma_sigma))
alma_d1_long = request.security(syminfo.tickerid, "D", f_alma(close, alma_len_long, alma_offset, alma_sigma))

// ALMA khung W1
alma_w1_short = request.security(syminfo.tickerid, "W", f_alma(close, alma_len_short, alma_offset, alma_sigma))
alma_w1_long = request.security(syminfo.tickerid, "W", f_alma(close, alma_len_long, alma_offset, alma_sigma))

// Vẽ biểu đồ
plot(alma_short, color=color.orange, title="ALMA Ngắn (Hiện tại)")
plot(alma_long, color=color.blue, title="ALMA Dài (Hiện tại)")
plot(alma_d1_short, color=color.green, title="ALMA Ngắn (D1)", linewidth=1)
plot(alma_d1_long, color=color.red, title="ALMA Dài (D1)", linewidth=1)
plot(alma_w1_short, color=color.purple, title="ALMA Ngắn (W1)", linewidth=1)
plot(alma_w1_long, color=color.gray, title="ALMA Dài (W1)", linewidth=1)

// Chênh lệch ALMA hiện tại
plot(alma_short - alma_long, title="Chênh lệch ALMA", color=color.fuchsia, style=plot.style_columns)

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.