I've changed a lot of stuff since I discovered that TradingView uses adjusted price on daily's close instead of close's value from the last candle. So, there are sensible changes in the whole code and I recommend look closer before start using this new version.
Enjoy!