TNT
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Lazylady

//@version=5
indicator("TNT", overlay = true)

bsp = input(28,title="Body Size Period",group = "Time Periods")
map = input(28,title="Smoothing Period",group = "Time Periods")

bs = ta.sma(math.abs(close - open),bsp)

MA = ta.sma(bs,map)

//plot(bs)
//plot(MA,color=color.red)

trending = color.new(input.color(color.green, title = "Trending", group = "Background Color"),85)
rangebound = color.new(input.color(color.red, title = "Range Bound", group = "Background Color"),85)

sessioncolor = if bs>MA
    trending
else
    rangebound

bgcolor(sessioncolor)