study("[RS]Log Channel V0", overlay=true) smooth = input(title='ma smooth', type=integer, defval=4) length = input(title='l', type=integer, defval=6) src = input(title='src', type=source, defval=hl2) logc = log(sqrt(src)) lower = sma(close - logc*0.5, smooth) upper = sma(lower + logc, smooth) midline = avg(lower,upper) smooth_upper = upper*0.25 + highest(upper, length)*0.75 smooth_lower = lower*0.25 + lowest(lower, length)*0.75 smooth_midline = avg(smooth_upper, smooth_lower) plot(midline, color=lime) plot(lower, style=circles, color=lower == smooth_lower ? na : falling(lower, 1) ? na : lime, linewidth=2) plot(upper, style=circles, color=upper == smooth_upper ? na : rising(upper, 1) ? na : red, linewidth=2) plot(smooth_midline, color=red) plot(smooth_lower, color=black) plot(smooth_upper, color=black)
I know this is perhaps moot but you can use a logarithm property to evaluate logc = log(sqrt(src)) = log((src)^(0.5)) = 0.5 * log(src), since: log(a^b) = b * log(a) rule. That way you do not have to apply sqrt(src) before applying log().
** This is not to be patronizing. Just a flashback to my Numerical Analysis classes from college back in the day of optimizing algorithm calculations, reducing calculation complexity and time.