Based on version by leojez.
Adds a 3rd standard deviation level.
Twice as fast as original version.
Refactored and simplified source code.
HOW TO USE
Load your chart
Adjust the timeframe and zoom of the chart so that the trend you're interested in is in view.
Add the indicator
Use the measuring tool to measure the number of bars from the start of the trend to the latest candle.
Open settings for the indicator.
Set the length value to the number of bars that you noted.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.