TradingView
BigBitsIO
24 set 2019 18:44

Scripting Tutorial 6 - Triple Many Moving Averages Forecasting 

Bitcoin / US Dollar Perpetual Inverse Swap ContractBitMEX

Descrizione

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.

Features:
- 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.

Note di rilascio

Added some more code comments to clarify what is happening in the script.

Note di rilascio

Added some validations, metadata.
Commenti
yusufbayraktar01
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
racebreaker
This is for SMA and not for EMA right?
tsuicm64ken
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 =)
geniusofthane
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.
Andrew_Fineman
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?
SefuAlthaus
@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.
Altro