OPEN-SOURCE SCRIPT

Mean and Standard Deviation Lines

Cập nhật
Description:

Calculates the mean and standard deviation of close-to-close price differences over a specified period, providing insights into price volatility and potential breakouts.
Manually calculates mean and standard deviation for a deeper understanding of statistical concepts.
Plots the mean line, upper bound (mean + standard deviation), and lower bound (mean - standard deviation) to visualize price behavior relative to these levels.
Highlights bars that cross the upper or lower bounds with green (above) or red (below) triangles for easy identification of potential breakouts or breakdowns.
Customizable period input allows for analysis of short-term or long-term volatility patterns.

Probability Interpretations based on Standard Deviation:

50% probability: mean or expected value
68% probability: Values within 1 standard deviation of the mean (mean ± stdev) represent roughly 68% of the data in a normal distribution. This implies that around 68% of closing prices in the past period fell within this range.
95% probability: Expanding to 2 standard deviations (mean ± 2*stdev) captures approximately 95% of the data. So, in theory, there's a 95% chance that future closing prices will fall within this wider range.
99.7% probability: Going further to 3 standard deviations (mean ± 3*stdev) encompasses nearly 99.7% of the data. However, these extreme values become less likely as you move further away from the mean.

Key Features:

Uses manual calculations for mean and standard deviation, providing a hands-on approach.
Excludes the current bar's close price from calculations for more accurate analysis of past data.
Ensures valid index usage for robust calculation logic.
Employs unbiased standard deviation calculation for better statistical validity.
Offers clear visual representation of mean and volatility bands.

Considerations:

Manual calculations might have a slight performance impact compared to built-in functions.
Not a perfect normal distribution: Financial markets often deviate from a perfect normal distribution. This means probability interpretations based on standard deviation shouldn't be taken as absolute truths.
Non-stationarity: Market conditions and price behavior can change over time, impacting the validity of past data as a future predictor.
Other factors: Many other factors influence price movements beyond just the mean and standard deviation.
Always consider other technical and fundamental factors when making trading decisions.

Potential Use Cases:

Identifying periods of high or low volatility.
Discovering potential breakout or breakdown opportunities.
Comparing volatility across different timeframes.
Complementing other technical indicators for confirmation.
Understanding statistical concepts for financial analysis.
Phát hành các Ghi chú
made some changes on how the mean and standard deviation are calculated and I think this time it works.
Phát hành các Ghi chú
changed some colors for clarity and make some correction to the descriptions.
Phát hành các Ghi chú
updated the math. This indicator is a work in progress so be careful when you use it.
Phát hành các Ghi chú
changed default period length to 100.
Phát hành các Ghi chú
cleaned up the script and added copyright info.
Phát hành các Ghi chú
Improved the math and removed anomaly detection to keep the script consistent with its name.
Phát hành các Ghi chú
corrected the math and renamed period into window because it is more appropriate. The window represents the analysis window for the transform pricing model which takes the statistical properties of the past and uses them to make predictions on the future price.
Phát hành các Ghi chú
Updated the code to use built-in functions to calculate sample statistics and added a new variable so the analysis window for the mean is separate from the analysis window of standard deviation. Mean is now renamed to expected value.
Phát hành các Ghi chú
removed link for compliance.
Phát hành các Ghi chú
updated the license to CC BY-NC-ND 4.0
Bands and Channelsforecastingstatistics

Mã nguồn mở

Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?


Ngoài ra, trên:

Thông báo miễn trừ trách nhiệm