This is a non-repaint version of the built-in linear regression indicator in pine. It creates moving bands where the current bar matches the built-in Linear Regression indicator exactly (see screenshot). The key to replicating the built-in function is calculating the std deviation across the length of bars away from the current Linear Regression line, as opposed to the linear regression line that would have been calculated at the historic bar.
Software Engineer and FX, Options, Crypto Trader. Previously worked at large options market maker. If you like my scripts and would like to donate: Bitcoin: 179ETrGo3FCVcnBV8i1uc4J8YHFRknYytz Eth: 0x73d59A8214FD70053aF37E9700692e25de441245