Scripting Tutorial 6 - Triple Many Moving Averages Forecasting

This script is for a triple moving average indicator where the user can select from different types of moving averages, price sources and lookback periods.

- 3 Moving Averages with variable MA types, periods, price sources and ability to disable each individually
- Crossovers are plotted on the chart with detailed information regarding the crossover (Ex: 50 SMA crossed over 200 SMA )
- Forecasting available for all three MAs. MA values are forecasted 5 values out and plotted as if a continuation to the MA.
- Forecast bias also applies to all forecasting. Bias means we can forecast based on an anticipated bullish , bearish or neutral direction in the market.
- To understand bias, please read the source code, or if you can't read the code just send me a message on here or Twitter . Twitter should be linked on my profile.

This script is meant as an educational script with well-formatted styling, and references for specific functions.
Notas de Lançamento: Added some more code comments to clarify what is happening in the script.
Notas de Lançamento: Added some validations, metadata.
Script de código aberto

No verdadeiro espírito TradingView, o autor deste script o publicou com código aberto, para que os traders possam compreendê-lo e verificá-lo. Um brinde ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para utilizá-lo em um gráfico.

Quer usar esse script no gráfico?
Like and follow!

💻 Website:
📺 YouTube:
🎮 Discord:
🐦 Twitter:
💸 Save $30 on TradingView Paid Plan:


I guess there should be a correction for MA3Source, I guess it should be MA3Source and I guess you should change them all.
If i am incorrect please notify me. Regards and thanks for the development.

MA3Forecast2 = (ma(MA3Type, MA3Source, MA3Period - 2) * (MA3Period - 2) + ((MA1Source * 2) + (Bias * 2))) / MA3Period
+6 Resposta
This is for SMA and not for EMA right?
+3 Resposta
There are "Bias" in line 117 and line 127, are they the same thing?
or Pine allows the elements in a function have the same Spelling as other Variables?

sorry for the bad expression, I am not very good at English and Coding,
Thank you =)
Thank you for good script.

I don't see code for volume (i tried too), which i tried as well.

I am actually looking for what is shown in image in this article i.e. show volume besides candles and emas...also wish to add macd in separate pane. I couldn't find any such sample code.
Is there a reason why i am getting an error when attempting to use an EMA of 5? The program is telling me that i cannot have a value of "0" in the EMA function. It will, however, display a result when i change the value to anything greater than 5. Any thoughts?
surishashank Andrew_Fineman
@Andrew_Fineman, It is because when you make the 5th forecast in this example it causes the "MAPeriod - 5" part to be 5-5 = 0.