Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 1/25/2010(UTC) Posts: 44 Location: Rome, IT
|
Hi Everybody,
below the Risk Metrics code for Metastock by JP Morgan:
lambda:=Input("Lambda factor",0.01,0.8,0.10);
returns:= 100*Log(C/Ref(C,-1));
avgreturns:= PREV*(1-lambda )+ returns*lambda;
vola:=Sqr(Power(PREV,2)*(1-lambda)+lambda*Power(returns-avgreturns,2));
vola;
Is it possible obtain the same or similar result without PREV function?
Thanks
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi Leverage
For the "avgreturns" variable substitute this:
periods:=2*(1/lambda)-1;
avgreturns:=Mov(",returns,periods,E);
or this.
periods:=2*(1/lambda)-1;
avgreturns:=ExtFml("MSTT.EMA",returns,Periods);
The standard Mov() function cannot handle fractional "period" values whereas the MSTT.EMA DLL function can.
For "vola" I have no idea.
Roy Edited by user Wednesday, January 14, 2015 12:03:55 AM(UTC)
| Reason: spelt word wrongly
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.