OPEN-SOURCE SCRIPT

Average of Highs, Lows, and Close (Excluding Last 15-min Bar)

//version=5
indicator("Average of Highs, Lows, and Close (Excluding Last 15-min Bar)", overlay=true)

// --- Variables to store cumulative values and counts ---
var float customSum = 0.0
var int candleCount = 0

// --- Get current session's end time for 15-minute time frame (NSE) ---
sessionEndTime = timestamp("GMT+5:30", year, month, dayofmonth, 15, 30)

// --- Custom calculation (excluding the last 15-min candle) ---
if (time < sessionEndTime - 15 * 60000) // Exclude last 15-min candle
customSum := customSum + (high + low + close) // Sum of high, low, and close
candleCount := candleCount + 1

// --- Final average calculation (if candles are counted) ---
averageValue = candleCount > 0 ? customSum / (candleCount * 3) : na // Divide by 3 for average of highs, lows, closes

// --- Reset daily values at the start of a new day ---
if (ta.change(time('D')))
customSum := 0.0
candleCount := 0

// --- Plotting the average value ---
plot(averageValue, title="Average (Highs + Lows + Close Excluding Last Bar) / 3", color=color.blue, linewidth=2)
Bands and ChannelsBreadth IndicatorsCandlestick analysis

نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الرمز في المنشور يخضع لقواعد‎‎قوانين الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟

إخلاء المسؤولية