OPEN-SOURCE SCRIPT

Weekly and Previous Week Highs, Lows, and Close

//version=5
indicator("Weekly and Previous Week Highs, Lows, and Close", overlay=true)

// --- Variables to store previous and current week data ---
var float prevWeekValue = na
var float currentWeekValue = na

// --- Detect start of a new week ---
newWeek = ta.change(time('W'))

// --- Reset weekly values at the start of the new week ---
if (newWeek)
// Calculate previous week value and store it
prevWeekValue := (ta.highest(high, 5) + ta.lowest(low, 5) + close[1]) / 3

// Reset current week data
currentWeekValue := (high + low + close) / 3
else
// Update current week's value
currentWeekValue := (math.max(currentWeekValue, (high + low + close) / 3))

// --- Plotting previous and current week values ---
plot(prevWeekValue, title="Previous Week Value (Highs + Lows + Close) / 3", color=color.red, linewidth=2)
plot(currentWeekValue, title="Current Week Value (Highs + Lows + Close) / 3", color=color.green, linewidth=2)
Bands and ChannelsBreadth Indicators

Mã nguồn mở

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

Bạn muốn sử dụng tập lệnh này trên biểu đồ?

Thông báo miễn trừ trách nhiệm