Implementing Triple Smoothed Moving Average in ProBuilder

19 Feb 2023
0 comment
0 attachment

The following ProBuilder code snippet demonstrates how to implement a triple smoothed moving average, which is a technique used to reduce the noise from price data in financial time series. This method involves smoothing a moving average multiple times to provide a clearer trend indication.

//Multiple smoothing moving average
// MA type (0=SMA,1=EMA,2=WMA,3=Wilder,4=Triangular,5=End point,6=Time series,7 = Hull (PRT v11 only),8 = ZeroLag (PRT v11 only))
period1=14
type1 = 0
period2=10
type2 = 0
period3=9
type3 = 0
src = customclose
avg = average[period1,type1](average[period2,type2](average[period3,type3](src)))
return avg

This code snippet creates a triple smoothed moving average based on user-defined parameters. Here’s a breakdown of how it works:

  • Definition of Parameters: The variables period1, period2, and period3 define the periods of the moving averages, and type1, type2, and type3 specify the types of moving averages. The types can range from simple moving average (SMA) to more complex types like Hull and ZeroLag moving averages.
  • Source Data: The variable src is set to customclose, which typically represents the closing prices of a financial instrument, although it can be customized to other price types or data points.
  • Calculating Nested Averages: The function average is used three times, each nested within the other. This nesting results in the source data being smoothed multiple times. The innermost average function calculates the first moving average based on period3 and type3. The result is then used as the input for the second average function, and so on, until the outermost average function computes the final smoothed moving average using period1 and type1.
  • Output: The final result, stored in the variable avg, is returned. This value represents the triple smoothed moving average of the input data, providing a smoother and potentially more reliable indicator than a single moving average.

This method is particularly useful in technical analysis for identifying longer-term trends and reducing the impact of short-term fluctuations.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/moyenne-mobile-a-lissage-multiple/#post-127614

Visit Link
What is a Snippet? A snippet is a small, reusable chunk of code designed to solve specific tasks quickly. Think of it as a shortcut that helps you achieve your coding goals without reinventing the wheel. How to Use: Simply copy the snippet and paste it into your project where needed. Don't forget to tweak it to fit your context. Snippets are not just time-savers; they're also learning tools to help you become a more efficient coder.
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Search Snippets

Showing some results...
Sorry, no result found!

Snippets Categories

global
35
indicator
133
strategy
171

Recent Snippets

How to Create a Simple MTF Trend Dashboard with EMA and SMA
indicator
This indicator builds a compact multi-timeframe (MTF) dashboard that shows whether price is trading above or below a [...]
How to Display Per-Bar Volume Accumulation in Real Time (Intrabar Updates)
global
This snippet tracks and displays the current bar’s accumulated volume while the bar is still forming, instead of only [...]
Ticks Counter: Count Tick Updates Per Bar on Tick or Time Charts
global
This snippet counts how many tick updates have occurred for the current bar by incrementing a per-bar counter on each [...]
How to Build a Step-Based Trailing Stop That Moves to Break-Even First
strategy
This snippet implements a step trailing stop that advances in fixed increments once price reaches predefined profit [...]
Utilizing Arrays to Track and Compare Indicator Values Within the Same Bar in ProBuilder
indicator
This ProBuilder code snippet demonstrates how to use arrays to compare the values of an indicator (RSI in this case) [...]
Logo Logo
Loading...