PowerLine by Dhruv
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © odhruvji

//@version=5
indicator("PowerLine by Dhruv", overlay = true, format=format.price, precision=2)

PowerLineP=input.int(42, "PowerLineP", minval=5, maxval=100, step=1)

PowerMax= ta.highest(high[1], PowerLineP)
PowerMin= ta.lowest(low[1], PowerLineP)
PowerMean=(PowerMax+PowerMin)/2

plot(PowerMax, title="PowerMax", color=color.green, transp=0)
plot(PowerMin, title="PowerMin", color=color.red, transp=0)
plot(PowerMean, title="PowerMean", color=color.black, transp=0)

colorcode=(close>PowerMean)?(close>close[1]?color.rgb(0, 150, 0, 10):color.rgb(0, 150, 0, 70)):(close>close[1]?color.rgb(255, 0, 0, 70):color.rgb(255, 0, 0, 10))
barcolor(color=colorcode)