How to I add a moving average to the below script? I added it manually on the chart , but I want It on the script. This is what it looks like on the daily chart. could not get the plot function to get it to work( see pic below ).
q1=MACD(Week(PERIODAMOUNT=1), BAR1=12, BAR2=26, OSC=9).Histogram; this worked
q2=MA(Week(PERIODAMOUNT=1), q1, BARS=20, STYLE=Center, CALC=Close); this did not work
From what i can see the Moving Averages vary because a Time Frame over ride is being used in the histogram script. On the Show View where the MA is included as part of the script, the timeframe override for the histogram to weekly is picked up by the MA, and weekly values are used (so the data is padded, that is why the line is straight for each 5 bar segment). That means the Moving Average is calculating the average of the last 20 weekly histogram values.
With the other show view where the MA has been manually applied, the MA has no reference to the time frame override being used, as a result it calculates using the last 20 (daily) values of the histogram.
When you change the charts time frame to weekly, you will see that both MA lines match.
The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.