//@version=5 indicator("Volume Flow Indicator [birdsongs]", shorttitle="Volume Flow [birdsongs]", overlay=false) // Set overlay to false // User inputs for customization length = input.int(50, "VFI Length", title="Length of the moving average for VFI calculation") cutoffMultiplier = input.float(0.2, "Cutoff Multiplier", step=0.01, title="Multiplier to adjust the sensitivity of volume cutoff") smooth = input.int(3, "Smoothing Length", title="Number of periods for smoothing the VFI") // Calculate Typical Price and Volume Force typicalPrice = (high + low + close) / 3 vForce = volume * (typicalPrice - nz(typicalPrice[1])) / ta.atr(length) // Calculate Cutoff based on the average true range cutoff = ta.atr(length) * cutoffMultiplier // Initialize array to store values var float[] forces = array.new_float(0) // Fill the array with volume force values that exceed the cutoff if array.size(forces) >= length array.shift(forces) array.push(forces, math.abs(vForce) > cutoff ? vForce : 0) // Calculate the VFI vfi = array.sum(forces) / volume // Smooth the VFI for better visualization smoothedVfi = ta.sma(vfi, smooth) // Plotting the VFI as an overlay on the price chart plot(smoothedVfi, "Smoothed VFI", color=color.blue) hline(0, "Zero Line", color=color.gray) // Optional: Change background color to indicate strong positive trends only bgcolor(smoothedVfi > 1 ? color.new(color.green, 90) : na, title="Trend Background")