Displacement (Two FVGs)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AJ7919

//@version=5
indicator('Displacement (Two FVGs)', overlay=false)

bullishFvg = low[1] > high[3] and low[2] > high[4]
bearishFvg = high[1] < low[3] and high[2] < low[4]

bull=bullishFvg?2:0
bear=bearishFvg?-2:0


plot(bull, color= color.green, title='Bullish Displacement', linewidth=1, style = plot.style_columns )
plot(bear, color= color.red, title='Bearish Displacement', linewidth=1, style = plot.style_columns)


bgcolor(bull ? color.new(color.green,90) : bear ? color.new(color.red,90) : na)
plot(0, color=color.new(color.black, 0))

alertcondition(bullishFvg, title = "Two Bullish FVGs", message = "Potential Bullish Displacemen")
alertcondition(bearishFvg, title = "Two Bearish FVG", message = "Potential Bearish Displacement")

if bullishFvg
    alert("Potential Bullish Displacement", alert.freq_once_per_bar_close)

if bearishFvg
    alert("Potential Bearish Displacement", alert.freq_once_per_bar_close)