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.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.