OPEN-SOURCE SCRIPT
Standard Deviation Volatility Indicator

Standard Deviation Volatility Indicator
This indicator is constructed using the logarithmic returns of a price series and computing its standard deviation to estimate volatility. It then uses this volatility estimate to produce levels above and below the current price. It concludes by calculating the stochastic value based on these volatility levels.
Settings and Inputs:
SD Settings:
Standard Deviation Source: Defines the price series for which volatility is being calculated, default is the closing price.
Standard Deviation Period: A factor used to adjust the standard deviation.
Standard Deviation Length: Defines the number of periods over which the standard deviation is calculated.
Enable Smoothing?: Option to activate a smoothing function for the final output of the indicator.
MA Smoothing Length: Defines the number of periods for the moving average used to smooth the final output.
Indicator Logic:
Logarithmic Returns: Calculates the natural logarithm of the ratio of consecutive price values to determine returns.
Standard Deviation: Computes the standard deviation of these returns over a specified length n.
Historical Volatility (Hv): Uses the previously computed standard deviation as a proxy for historical volatility.
Levels Calculation: Uses the historical volatility to derive multiple levels above (SD1, SD2, SD3) and below (SD1_, SD2_, SD3_) the current price. An average for both sets of levels is then computed (SDM and SDM_).
Stochastic Value: The indicator calculates a stochastic value using the third level of the above and below computed values (SD3 and SD3_).
Smoothing: If smoothing is enabled, the stochastic value is smoothed using an exponential moving average of a specified length.
Output:
If the smoothing option is selected, the final output is the smoothed stochastic value.
Otherwise, the raw stochastic value is given.
This indicator is constructed using the logarithmic returns of a price series and computing its standard deviation to estimate volatility. It then uses this volatility estimate to produce levels above and below the current price. It concludes by calculating the stochastic value based on these volatility levels.
Settings and Inputs:
SD Settings:
Standard Deviation Source: Defines the price series for which volatility is being calculated, default is the closing price.
Standard Deviation Period: A factor used to adjust the standard deviation.
Standard Deviation Length: Defines the number of periods over which the standard deviation is calculated.
Enable Smoothing?: Option to activate a smoothing function for the final output of the indicator.
MA Smoothing Length: Defines the number of periods for the moving average used to smooth the final output.
Indicator Logic:
Logarithmic Returns: Calculates the natural logarithm of the ratio of consecutive price values to determine returns.
Standard Deviation: Computes the standard deviation of these returns over a specified length n.
Historical Volatility (Hv): Uses the previously computed standard deviation as a proxy for historical volatility.
Levels Calculation: Uses the historical volatility to derive multiple levels above (SD1, SD2, SD3) and below (SD1_, SD2_, SD3_) the current price. An average for both sets of levels is then computed (SDM and SDM_).
Stochastic Value: The indicator calculates a stochastic value using the third level of the above and below computed values (SD3 and SD3_).
Smoothing: If smoothing is enabled, the stochastic value is smoothed using an exponential moving average of a specified length.
Output:
If the smoothing option is selected, the final output is the smoothed stochastic value.
Otherwise, the raw stochastic value is given.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.