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.

Script open-source

Dans le véritable esprit de TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par le règlement. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.

Vous voulez utiliser ce script sur un graphique ?