Update : This was a code from long long time ago and pine functionality has changed so many of the users are getting error related to max_bars_back referencing length. To avoid such a possible problem all together, I've replaced line.new function with plot function.
This is an opensource code, so I've left the editing to your choice in the plot function, change it as you wish to use it.
Regards!