LastBattle

Single Timeframe Moving Average

Provides Moving average of 200 and 50 at the specific timeframe regardless of what interval you're looking at.
Saving the need to change it manually each time you switch the interval.

In this chart, I am looking at 4H interval with EMA of 50/200 of daily timeframe.

Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

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.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
study(title="Single Timeframe Moving Average", shorttitle="Single TF MA", overlay=true)

len_sma_long = input(200, minval=1, title="Long Simple Moving Average")
len_sma_short = input(50, minval=1, title="Short Simple Moving Average")
resCustom = input(title="Time interval (W, D, [min])", type=string, defval="D")

sma_long = security(tickerid, resCustom, sma(close, len_sma_long))
sma_short = security(tickerid, resCustom, sma(close, len_sma_short))
src = security(tickerid, resCustom, close)

s2 = cross(sma_long, sma_short) ? src : na
plot(sma_long, color=green)
plot(sma_short, color=red)

plotshape(cross(sma_long, sma_short) ? sma_long  : na, style=shape.xcross, text="ALERT")