OPEN-SOURCE SCRIPT

EMA & Bollinger Bands

This indicator combines three main functionalities into a single script:

1. Exponential Moving Average (EMA):
- Purpose: Calculates and plots the EMA of a chosen price source.
- Inputs:
- EMA Length: The period for the EMA calculation.
- EMA Source: The price series (such as close) used for the EMA.
- EMA Offset: Allows shifting the EMA line left or right on the chart.
- Output: A blue-colored EMA line plotted on the chart.

2. Smoothing MA on EMA:
- Purpose: Applies a secondary moving average (MA) on the previously calculated EMA. There is also an option to overlay Bollinger Bands on this smoothed MA.
- Inputs:
- Smoothing MA Type: Options include "None", "SMA", "SMA + Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", and "VWMA".
- Selecting "None" disables this feature.
- Choosing "SMA + Bollinger Bands" will additionally plot Bollinger Bands around the smoothed MA.
- Smoothing MA Length: The period used to calculate the smoothing MA.
- BB StdDev for Smoothing MA: The standard deviation multiplier for the Bollinger Bands (applies only when "SMA + Bollinger Bands" is selected).
- Calculation Details:
- The chosen MA type is applied to the EMA value.
- If Bollinger Bands are enabled, the script computes the standard deviation of the EMA over the smoothing period, multiplies it by the specified multiplier, and then plots an upper and lower band around the smoothing MA.
- Output:
- A yellow-colored smoothing MA line.
- Optionally, green-colored upper and lower Bollinger Bands with a filled background if the "SMA + Bollinger Bands" option is selected.

3. Bollinger Bands on Price:
- Purpose: Independently calculates and plots traditional Bollinger Bands based on a moving average of a selected price source.
- Inputs:
- BB Length: The period for calculating the moving average that serves as the basis of the Bollinger Bands.
- BB Basis MA Type: The type of moving average to use (options include SMA, EMA, SMMA (RMA), WMA, and VWMA).
- BB Source: The price series (such as close) used for the Bollinger Bands calculation.
- BB StdDev: The multiplier for the standard deviation used to calculate the upper and lower bands.
- BB Offset: Allows shifting the Bollinger Bands left or right on the chart.
- Calculation Details:
- The script computes a basis line using the selected MA type on the chosen price source.
- The standard deviation of the price over the specified period is then multiplied by the provided multiplier to determine the distance for the upper and lower bands.
- Output:
- A basis line (typically drawn in a blue tone), an upper band (red), and a lower band (teal).
- The area between the upper and lower bands is filled with a semi-transparent blue background for easier visualization.

---

How It Works Together

- Integration:
The script is divided into clearly labeled sections for each functionality. All parts are drawn on the same chart (overlay mode enabled), providing a comprehensive view of market trends.

- Customization:
Users can adjust parameters for the EMA, the smoothing MA (and its optional Bollinger Bands), as well as the traditional Bollinger Bands independently. This allows for flexible customization depending on the trader's strategy or visual preference.

- Utility:
Combining these three analyses into one indicator enables traders to view:
- The immediate trend via the EMA.
- A secondary smoothed trend that might help reduce noise.
- A volatility measure through Bollinger Bands on both the price and the smoothed EMA.

---

This combined indicator is useful for technical analysis by providing both trend-following (EMA and smoothing MA) and volatility indicators (Bollinger Bands) in one streamlined tool.

Penafian