Mean absolute deviation

I'd like to code Clifford Sherry's mean absolute deviation bands. Dow anyone have the code for a mad() function?

Best to all,

John
mult = 2;
period = 20;
mean = MA(C, period);
for (i = 0, cs = 0; i < period; i++) {
	cs += abs(Ref(C,-i) - mean);
}
dev = mult*cs/period;
mad_up = mean+dev;
mad_dn = mean-dev;

Plot( C, "Price", colorDefault, styleBar );
Plot( mad_up, "MAD up", colorRed );
Plot( mad_dn, "MAD dn", colorRed );
9 Likes

Thanks fxshrat, you really are the best! If our paths ever cross a very nice dinner is on me.

 John
5 Likes

Thank you for the invitation! Let's see...

Since I like challenges maybe I'll cross the Atlantic like this:
32087000

As for the 2nd part of your first sentence I do not agree. But thank you for your kind words.

2 Likes

I think that I will leave hitch hiking on whale sharks to you. However, I do try to cross the Atlantic a couple of times a year, albeit at a slightly higher altitude. This October I plan visit Berlin and Paris.

3 Likes

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