OPEN-SOURCE SCRIPT

Forex Sessions + High/Low Volume Indicator

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

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.