SuperTrend indicator is really famous but there is so little magic behind it. All it is essentially is an ATR trail. The logic is real simple! On every bar close we build a top and botom channel using current ATR value with multiplier. After that if we get a Close above the channel we hide the top channel and color the bottom channel green. We do the opposite if we get the Close below the bottom channel value. The trail is also real simple. If the current close minus the atr value is actually smaller than the previous one whilst going up we use the previous value. That is why the plot is horizontal sometimes. If the value is higher we tighten it up. Please follow up to see the code review.