kapuzmustafa

Groupped SMA with Custom Lenght by Mustafa KAPUZ

This script is a custom implementation of grouped Simple Moving Averages (SMA) with added Bollinger Bands

Key Features:

Customizable Length (n): Allows users to set the length for the SMA calculation. The length is the number of bars used to calculate the average. This is input by the user and can be adjusted to analyze different time periods.
Standard Deviation Multiplier (StdDev): This input allows users to customize the width of the Bollinger Bands. A higher multiplier results in wider bands, and a lower multiplier results in narrower bands.
Grouped Calculation: Instead of calculating the SMA on a rolling basis, this script groups the data in sets of n (as per the user-defined length) and calculates the SMA for each group. After each group, the calculation resets.
Bollinger Bands: Based on the SMA calculated for each group, the script calculates the standard deviation of prices within the group. Using the standard deviation and the standard deviation multiplier (StdDev), it computes the upper and lower Bollinger Bands.
Dynamic Visualization: For each completed group of n bars, the script draws lines on the chart representing the upper band, lower band, and the SMA itself. These lines help visualize the volatility and the average price level for each group.

How It Works:

Data Grouping: For every candle/bar on the chart, the script sums up the closing prices and counts the number of bars until it reaches the user-defined length (n). It stores closing prices in an array for further calculations.
Average Calculation: Once the count reaches n, it calculates the average closing price for the group and resets the sum and count for the next group.
Standard Deviation and Bollinger Bands: With the average calculated, it then computes the standard deviation of the closing prices within the group. This standard deviation, multiplied by the user-defined StdDev multiplier, determines the distance of the Bollinger Bands from the average.
Drawing Lines: Finally, the script visually represents these calculations on the chart by drawing lines for the upper band, lower band, and the average itself for each group.

Purpose and Use:

This script is useful for traders and analysts who prefer to examine price movements and volatility in fixed intervals or groups of bars, rather than the continuous rolling averages provided by traditional SMA and Bollinger Band indicators. By adjusting the length and standard deviation multiplier, users can tailor the indicator to fit various trading strategies, time frames, and market conditions. This grouped approach can provide unique insights into market trends, potential reversals, and volatility patterns that might not be as evident with standard indicators.

开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?