How to plot 200-day moving average at weekly chart ?

How to plot 200-day moving average at weekly chart ?

Please read this

with special attention to important text in orange boxes.

1 Like

I believe you need a minimum of 3 or 4 years historical data to generate 200D MA on weekly chart.
I assume that is the problem (you don't have 3Y or 4Y historical data),
am i right ?

I only get 140D MA on weekly chart, with data less than 3 years (Mar2020 - Dec2022)


Thank you very much for answering, could you show your AFL ?

no need AFL
you just need to drag&drop the MA into your chart.
but make sure you have enough historical data, other wise it won't show up.


the example chart is using H1 and MA500, not Weekly chart

1 Like

@Caio if you are looking to use multiple time frames of data then you need to carefully read the information in @Tomasz post. @ab-ami answers do not seem to have anything to do with plotting a DAILY moving average with WEEKLY charting.

Pay attention to the note in the user guide,

PLEASE NOTE that you can only compress data from shorter interval to longer interval. So when working with 1-minute data you can compress to 2, 3, 4, 5, 6, ....N-minute data. But when working with 15 minute data you can not get 1-minute data bars. In a similar way if you have only EOD data you can not access intraday time frames.

So if you want to use Weekly data you can not access a daily moving average. But using daily data (and a daily moving average) you can plot weekly O/H/L/C

1 Like

In order to generate 200MA on weekly chart, with or without AFL, you must have enough historical data, if you drag&drop the MA into the chart and see nothing, then i believe your data is not enough, so even using AFL to plot MA will get the same result.
just slide the Periods from 20 to 100 then try 200 to see if your data is enough.


it would be better if you could show screenshot of howmuch historical data on your database.

see my first pic, my database started from march/april 2020.
and it was not enough to generate 200MA, only 142MA on weekly chart.

What you are doing is plotting the 200MA of weekly data, what OP wants is 200MA of Daily data on a weekly chart. In this case, even if one has 250 Daily bars which is approximately 1 year, you will see the MA plotting on a Weekly chart.
For that, as @portfoliobuilder suggested, use TimeFrame functions but the caveat is you cannot fetch data from a lower time frame than what is set in time frame of chart or periodicity of Analysis.

1 Like

@nsm51 would you mind show the difference with pictures ?

@nsm51 would you mind show us with pictures ?


what do you mean with DAILY moving average ?

my first picture is from weekly chart
what do you mean with " do not seem to have anything to do with plotting a DAILY moving average with WEEKLY charting."

Tomasz quoted this in the 2nd post. Kindly go through it, and also understand what OP wants.
OP wants 200 daily-MA on a "Weekly" chart.
The link has many examples, first clear the inner workings of AB.

@Caio ok please let me know if i did misinterpreted your query
hope you found the workaround

see if this helps to understand

For that, put the Formula in DAILY chart.

ma200 = EMA(C, 200);
dt = DateTime();
dt = TimeFrameCompress( dt, inWeekly, compressOpen);
cMa200 = TimeFrameCompress( ma200, inWeekly);

Plot(C, "D_C", colorDefault, styleBar);		// This is Daily candle
Plot(ma200, "n200", colorRed, styleLine);

Plot(ma200, "D200", colorWhite, styleLine);

Plot(C, "W_C", colorDefault, styleCandle);	// This is weekly candle
Plot(cMa200, "cW200", colorYellow, styleLine);
Plot(EMA(C,200), "W200", colorGreen, styleLine);

_N( Title = StrFormat( "Daily chart Axis date={{DATE}} \ncompressed weekly date=" +
	datetimetostr( SelectedValue( dt)) + "\n{{VALUES}}" ) );

if you see, Red and White are overlap as they are not affected. They are 200 DMA plots.
What OP is wants is Yellow (compressed 200DMA on weekly bars) but what your Formula will do in weekly is Green.

Also, see how the Date/Time when compressed will align correctly in weekly. The Date axis of Daily will not align with weekly bars.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.