[TTI] Price confirmation indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TintinTrading

//@version=5
indicator("[TTI] Price confirmation indicator", overlay = true)

// Input settings
price_up_color = input.color(color.rgb(0, 51, 255), "Price Up Color")
price_down_color = input.color(color.rgb(135, 25, 155), "Price Down Color")

// Determine up and down days
isUpDay = close > close[1]
isDownDay = close < close[1]

// Calculate the 50DSMA volume
avgVolume = ta.sma(volume, 50)
volDifference = (volume - avgVolume) / avgVolume * 100


// Determine the transparency based on volume difference
var transparency = 0
if volDifference > 40
    transparency := 100
else if volDifference > 20
    transparency := 80
else if volDifference > 0
    transparency := 60
else if volDifference > -20
    transparency := 40
else if volDifference > -40
    transparency := 20
else if volDifference > -80
    transparency := 10
else
    transparency := 100


// Color bars based on the conditions
barcolor(isUpDay and volDifference > -80 ? color.new(price_up_color, 100 - transparency) : 
         isDownDay and volDifference > -80 ? color.new(price_down_color, 100 - transparency) : 
         volDifference <= -80 ? color.new(color.orange, 0) : na)
