Skip to main content

LWMA - Linearly Weighted Movong Average for Amibroker (AFL)

extremist about 14 years ago Amibroker (AFL)

  • Rating:
    5 / 5 (Votes 2)
  • Tags:
    amibroker

in a 15-day linearly-weighted moving average, today’s closing price is multiplied by 15, yesterday’s by 14, and so on until day 1 in the period’s range is reached. These results are then added together and divided by the sum of the multipliers (15 + 14 + 13 + … + 3 + 2 + 1 = 120).

The linearly weighted moving average was one of the first responses to placing a greater importance on recent data. The popularity of this moving average has been diminished by the exponential moving average, but none the less it still proves to be very useful.
From : investopedia.

I’ve done the coding only.
see if it could help u in improving ur systems.

Rho investment services
Rohan Patel.
rhn_patel2rediffmail.com

Screenshots

Indicator / Formula

Copy & Paste Friendly
function LWMA( P, per )
{
s=0;
pa=0;

for( i = 0; i < per; i++ ) 
{
s=s+(Ref(P,-i)*(per-i));
pa=pa+(per-i);
}
return (s/pa);
}

P = ParamField("Price field");
Periods = Param("Periods", 15, 2, 300, 1, 10 );

Plot(LWMA( P, Periods ), "LWMA("+Periods +")", ParamColor( "LWMA Color", colorCycle ), ParamStyle("LWMA Style") ); 

2 comments

almost 14 years ago

Mr. Anandnst……
Perhaps u don’t know how to use LWMA.
And i neither said like this is the great indicator or like tht.

And for ur knowledge LWMA is used in calculating TSR .
U can find code for TSR on net. and see for yourself whether it is useful or not.

but any time better than ur kind of cut paste codes.

coding is mine at least….

thanx….

Leave Comment

Please login here to leave a comment.