OPEN-SOURCE SCRIPT

Forex Sessions + High/Low Volume Indicator

25
//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)

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

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.