Note: This script does not perform well on its own and is meant to inspire other coders, just sharing it because why not :)
The idea is simple, highest only gets calculated for green candles, lowest only gets calculated for red candles. a yellow dot gets created when a candle gets below lowest line and closes bullish, vise versa for red dots.