OPEN-SOURCE SCRIPT

Robust Bollinger Bands with Trend Strength

Cập nhật
The "Robust Bollinger Bands with Trend Strength" indicator is a technical analysis tool designed assess price volatility, identify potential trading opportunities, and gauge trend strength. It combines several robust statistical methods and percentile-based calculations to provide valuable information about price movements with Improved Resilience to Noise while mitigating the impact of outliers and non-normality in price data.

Here's a breakdown of how this indicator works and the information it provides:

Bollinger Bands Calculation: Similar to traditional Bollinger Bands, this indicator calculates the upper and lower bands that envelop the median (centerline) of the price data. These bands represent the potential upper and lower boundaries of price movements.

Robust Statistics: Instead of using standard deviation, this indicator employs robust statistical measures to calculate the bands (spread). Specifically, it uses the Interquartile Range (IQR), which is the range between the 25th percentile (low price) and the 75th percentile (high price). Robust statistics are less affected by extreme values (outliers) and data distributions that may not be perfectly normal. This makes the bands more resistant to unusual price spikes.

Median as Centerline: The indicator utilizes the median of the chosen price source (either HLC3 or VWMA) as the central reference point for the bands. The median is less affected by outliers than the mean (average), making it a robust choice. This can help identify the center of price action, which is useful for understanding whether prices are trending or ranging.

Trend Strength Assessment: The indicator goes beyond the standard Bollinger Bands by incorporating a measure of trend strength. It uses a robust rank-based correlation coefficient to assess the relationship between the price source and the bar index (time). This correlation coefficient, calculated over a specified length, helps determine whether a trend is strong, positive (uptrend), negative (down trend), or non-existent and weak. When the rank-based correlation coefficient shifts it indicates exhaustion of a prevailing trend. Trend Strength" indicator is designed to provide statistically valid information about trend strength while minimizing the impact of outliers and data distribution characteristics. The parameter choices, including a length of 14 and a correlation threshold of +/-0.7, considered to offer meaningful insights into market conditions and statistical validity (p-value ,0.05 statistically significant). The use of rank-based correlation is a robust alternative to traditional Pearson correlation, especially in the context of financial markets.

Trend Fill: Based on the robust rank-based correlation coefficient, the indicator fills the area between the upper and lower Bollinger Bands with different colors to visually represent the trend strength. For example, it may use green for an uptrend, red for a down trend, and a neutral color for a weak or ranging market. This visual representation can help traders quickly identify potential trend opportunities. In addition the middle line also informs about the overall trend direction of the median.
Phát hành các Ghi chú
made correction to correlation coefficient threshold to +/-0.7

if want to make changes change here but 0.7 is ideal for the length 14.

// Define conditions for filling
fillUpTrend = robust_rank_corr > 0.7
fillDownTrend = robust_rank_corr < -0.7
fillNeutral = -0.7 < robust_rank_corr and robust_r
Phát hành các Ghi chú
Included the option to enter the threshold value to determine trend strength (varies between >0 to 1). Allowed the option to enter Trend Continuation length (means the current data point is part of a trend of length).
Phát hành các Ghi chú
minor correction.
Phát hành các Ghi chú
Made minor corrections in the code for fill color.
Bands and ChannelsbollingersbandcorrelationstatisticsVolatilityvolatilty

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 đồ?

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