Better moving average --how to get it

#1
hi friends

Here is a link for Richard d Ahrens -How to build a better moving average.
http://www.traders.com/index.php?option=com_content&view=article&id=2679&catid=48&Itemid=130

Build A Better Moving Average



Details
Parent Category: Featured Articles
Category: Indicators
Written by Richard D. Ahrens

Smooth Those Spikes

Is it possible to have a moving average that minimizes zigzags and powers through the occasional price spike? Find out here.

Smoothing market price data sounds like a simple concept, yet it is extremely difficult to do.

We apply moving averages to a time series to reduce noise and reveal the underlying trend with as little delay as possible. As such, there are three main elements we have to look at:

1)Trend — In digital signal processing (DSP),
this is also referred to as the signal.
2)Noise — Gyrations inherent in any complex system.
3)Delay — How long we have to wait to get an answer.

Moving averages essentially act as low-pass filters, that is, they are supposed to smooth away high-frequency noise and leave the lower-frequency signal for us to view. The problem is that large price changes can overwhelm the smoothing ability of short-term averages, and long-term averages introduce so much delay that the answers are of limited use by the time we get them.

IS THERE AN OPTIMAL AVERAGE?
A 200-day simple moving average (SMA) does a wonderful job of getting rid of noise, but you have to wait 100 days to get an answer. An 11-day simple moving average gets you an answer with only five days of delay, but doesn’t do much to quiet the noise. You can see why it’s difficult to smooth price data!

Rest of the article not available.
It is worth trying to find out what Richard d Ahrens actually said on how to get the job done.
===================
Things to think of
==================
Traders use 20,50,200 moving averages for short,medium and long term.
How about checking a 50ma after 25days to get a dependable result or trying to check noise free price average after 50days while using a 100day moving average?
It depends on the traders time frame choice. surely not a zone for daytraders.
or there can be a way for those trading above 30minute or 60minute timeframes.
 
Last edited:

pratapvb

Well-Known Member
#3
Adaptive moving average is there which does something similar

yes but could be interesting to check this out and compare with that
 
#4
No matter what smoothing algo we use it will have to follow the price . . .

The above article(part that is available) talks about 2 things, removing noise(i.e. smoothing) and delay (i.e Lag) but there are actually 3 things to consider with a MA

1. Smoothing
2. Lag
3. Overshoot

Try using Linear Regression curve to check what it means by overshoot . . . :D

From the freely available ones on Amibroker HMA would be the best one that sticks to the price showing the direction with minimum lag and overshoot and good smoothness.

From proprietary ones Jurik is supposed to be good . . .

But, no smoothing filter (i.e. moving average) can differentiate between a pullback and reversal . . .

Just to satisfy the mind one can use different tricks . . . like using variable period for generating the MA, for e.g. use bigger number for period when there is low volatility or volume traded is low or using faster smoothing when the range is big . . .

Cheers

:) Happy
 
#6
HappySinghJI

I agree, the best indicator is the PRICE.

Amit
No no I am not saying don't use any indicators . . .

for e.g. if i have to trade pure price action it will be nice to have WMA(Open,20), OR HMA(H,12) & HMA(L,12) on the chart

It gives a nice guiding structure to the chart, but if a trader understands the Lag & Overshoot about this indicator, he can make better use of it

Also having the same set of indicators or same layout on the chart for long time helps, by changing it every other day, we lose the advantage that the intuitive understanding brings.

Cheers

:) Happy
 
#8
Hi HAPPY SINGH

Here is a code by mohan yellayi-

please take a look and comment.

HTML:
mohan_yellayi
Here is the code that I constructed from the excel spreadsheet.
*/
Plot(C,"c",Colorcycle,styleCandle);
_SECTION_BEGIN( "Ahrens Moving Average" );

p1 = (O+C)/2;

p2 = (L+p1)/2;



for(i=1; i<BarCount; i++)

{

if(i<9)

{

KP[i] = p2[i];

MP[i] = p2[i];

}

else

{KP[i] = p2[i] - (MP[i-1] + MP[i-9])/2;



MP[i] = MP[i-1] + KP[i]/11;

}

} // end for loop

Plot(MP, "Ahrens Moving Average" , colorPaleBlue, styleLine |styleThick);

_SECTION_END( );

//try adding a ema 9 or wma9 for comparison-use white background
 
#9
Code:
Plot(WMA((2*L+O+C)/4,20), "Moving Average" , colorRed, styleThick);

Try to plot this alongside :thumb:

Cheers

:) Happy



EDIT:
To try to understand what any code is actually doing we need to modify it to make it simple and understandable . . .

same code as posted by ford . . . just simplified it by substitution . . .

Code:
Tp=p2=(2*L+O+C)/4;
for(i=9;i<BarCount;i++)	TP[i]=TP[i-1] + p2[i]/11 - TP[i-1]/22 - TP[i-9]/22;
Plot(TP, "Ahrens Moving Average" , colorRed, styleLine |styleThick);
 
Last edited:
#10
Dear Happy

I have seen so many times that you are so helpful to other forum members. I think that you are a person with good knowledge and a kind heart to help others. I pray to GOD to make you Happy always.
 

Similar threads