Description of the indicator.
This indicator was called «Multi-Moving Averages» because it has the ability to plot up to 10 different moving averages on the same chart, giving them a color that creates the appearance of being blurred, which significantly improves its visual aspect and interpretation. The only restriction is imposed by the number of moving averages available for each programming language; in the case of ThinkScript, there are five different types of averages: simple, exponential, weighted, Wilder's moving average, and Hull's moving average. In the case of PineScript, this number rises to nine, as it includes variants of the weighted moving average and Arnaud Legoux's moving average.
This indicator, like some already published, cannot be considered a variant of the existing ones, even though it implements pre-built functions; rather, it is a composite indicator, as it aims to integrate different indicators into the same code to enhance chart analysis. The user will be able to easily configure the type of moving average and its frequency; they can even choose how many moving averages to display at the same time.
The indicator was created in ThinkScript and then translated to other languages.
Explanation of the code.
Block 5-25: The explanation of the code for this indicator is quite simple. In this block, we define the type of price, the type of moving average, its periodicity, and then we repeat the same block ten times, one for each moving average.
Block 27-36: We graph the 10 moving averages using the plot indicator and pass the parameters to the pre-built MovingAverage function; similarly, we consider one line of code for each moving average.
Block 38-47: We add color and style to the lines of the ten moving averages that will be graphed. We use the SetDefaultColor attribute to assign a color to them and the CreateColor function to set the RGB code for the color in question.
Block 49-68: We added a couple of alerts for each moving average, which the user can enable or disable directly from the study settings in the current chart. One of the alerts is triggered when the price crosses above the moving average and the other when the price crosses below.