OPEN-SOURCE SCRIPT
Forex Sessions + High/Low Volume Indicator

//version=5
indicator("Forex Sessions + High/Low Volume Indicator", overlay=true, max_boxes_count=500)
// --- Inputs: Sessions ---
showAsia = input.bool(true, "Show Asia Session", group="Forex Sessions")
asiaTime = input.session("0000-0900", "Asia Session Time", group="Forex Sessions")
asiaColor = input.color(color.new(color.blue, 90), "Asia Color", group="Forex Sessions")
showLondon = input.bool(true, "Show London Session", group="Forex Sessions")
londonTime = input.session("0800-1700", "London Session Time", group="Forex Sessions")
londonColor= input.color(color.new(color.orange, 90), "London Color", group="Forex Sessions")
showNY = input.bool(true, "Show NY Session", group="Forex Sessions")
nyTime = input.session("1300-2200", "NY Session Time", group="Forex Sessions")
nyColor = input.color(color.new(color.red, 90), "NY Color", group="Forex Sessions")
// --- Inputs: Volume ---
volLen = input.int(20, "Volume MA Length", minval=1, group="Volume Logic")
highMult = input.float(1.5, "High Volume Threshold (x MA)", minval=1.0, group="Volume Logic")
lowMult = input.float(0.5, "Low Volume Threshold (x MA)", maxval=1.0, group="Volume Logic")
// --- Session Logic ---
is_session(sess) =>
not na(time(timeframe.period, sess, "UTC+0")) // Adjust "UTC+0" to your broker's timezone if needed
inAsia = showAsia and is_session(asiaTime)
inLondon = showLondon and is_session(londonTime)
inNY = showNY and is_session(nyTime)
// Plot Backgrounds
bgcolor(inAsia ? asiaColor : na)
bgcolor(inLondon ? londonColor : na)
bgcolor(inNY ? nyColor : na)
// --- Volume Logic ---
volMA = ta.sma(volume, volLen)
isHighVol = volume > (volMA * highMult)
isLowVol = volume < (volMA * lowMult)
// Highlight Candles based on Volume
barcolor(isHighVol ? color.yellow : isLowVol ? color.gray : na)
// --- Labels (Optional) ---
if isHighVol
label.new(bar_index, high, "HV", color=color.yellow, textcolor=color.black, style=label.style_label_down, size=size.tiny)
if isLowVol
label.new(bar_index, low, "LV", color=color.gray, textcolor=color.white, style=label.style_label_up, size=size.tiny)
// Plot Volume MA for reference (optional, shown in separate pane if not overlay)
// plot(volMA, "Volume MA", color=color.white)
indicator("Forex Sessions + High/Low Volume Indicator", overlay=true, max_boxes_count=500)
// --- Inputs: Sessions ---
showAsia = input.bool(true, "Show Asia Session", group="Forex Sessions")
asiaTime = input.session("0000-0900", "Asia Session Time", group="Forex Sessions")
asiaColor = input.color(color.new(color.blue, 90), "Asia Color", group="Forex Sessions")
showLondon = input.bool(true, "Show London Session", group="Forex Sessions")
londonTime = input.session("0800-1700", "London Session Time", group="Forex Sessions")
londonColor= input.color(color.new(color.orange, 90), "London Color", group="Forex Sessions")
showNY = input.bool(true, "Show NY Session", group="Forex Sessions")
nyTime = input.session("1300-2200", "NY Session Time", group="Forex Sessions")
nyColor = input.color(color.new(color.red, 90), "NY Color", group="Forex Sessions")
// --- Inputs: Volume ---
volLen = input.int(20, "Volume MA Length", minval=1, group="Volume Logic")
highMult = input.float(1.5, "High Volume Threshold (x MA)", minval=1.0, group="Volume Logic")
lowMult = input.float(0.5, "Low Volume Threshold (x MA)", maxval=1.0, group="Volume Logic")
// --- Session Logic ---
is_session(sess) =>
not na(time(timeframe.period, sess, "UTC+0")) // Adjust "UTC+0" to your broker's timezone if needed
inAsia = showAsia and is_session(asiaTime)
inLondon = showLondon and is_session(londonTime)
inNY = showNY and is_session(nyTime)
// Plot Backgrounds
bgcolor(inAsia ? asiaColor : na)
bgcolor(inLondon ? londonColor : na)
bgcolor(inNY ? nyColor : na)
// --- Volume Logic ---
volMA = ta.sma(volume, volLen)
isHighVol = volume > (volMA * highMult)
isLowVol = volume < (volMA * lowMult)
// Highlight Candles based on Volume
barcolor(isHighVol ? color.yellow : isLowVol ? color.gray : na)
// --- Labels (Optional) ---
if isHighVol
label.new(bar_index, high, "HV", color=color.yellow, textcolor=color.black, style=label.style_label_down, size=size.tiny)
if isLowVol
label.new(bar_index, low, "LV", color=color.gray, textcolor=color.white, style=label.style_label_up, size=size.tiny)
// Plot Volume MA for reference (optional, shown in separate pane if not overlay)
// plot(volMA, "Volume MA", color=color.white)
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。