Bollinger Bands Trend Indicator

Somebody please help in making a coding an indicator for the below

lower = abs(lowerBB(20) - lowerBB(50))
upper = abs(upperBB(20) - upperBB(50))
BBTrend = (lower - upper) / middleBB(20)