logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
MS Support  
#1 Posted : Thursday, February 7, 2013 12:09:22 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,934

Thanks: 85 times
Was thanked: 154 time(s) in 150 post(s)
Ron McEwan’s article, “The Volatility (Regime) Switch Indicator” explained how to calculate the indicator of the same name. This can be added to MetaStock with the following formula:

dr:= ROC(C,1,$)/Mov(C,2,S);
vola:= Stdev( dr, 21);
( (Ref( vola, -1) <= vola ) +
(Ref( vola, -2) <= vola ) +
(Ref( vola, -3) <= vola ) +
(Ref( vola, -4) <= vola ) +
(Ref( vola, -5) <= vola ) +
(Ref( vola, -6) <= vola ) +
(Ref( vola, -7) <= vola ) +
(Ref( vola, -8) <= vola ) +
(Ref( vola, -9) <= vola ) +
(Ref( vola, -10) <= vola ) +
(Ref( vola, -11) <= vola ) +
(Ref( vola, -12) <= vola ) +
(Ref( vola, -13) <= vola ) +
(Ref( vola, -14) <= vola ) +
(Ref( vola, -15) <= vola ) +
(Ref( vola, -16) <= vola ) +
(Ref( vola, -17) <= vola ) +
(Ref( vola, -18) <= vola ) +
(Ref( vola, -19) <= vola ) +
(Ref( vola, -20) <= vola ) + 1) / 21
wabbit  
#2 Posted : Thursday, February 7, 2013 4:26:08 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
If preferred, you can make the code more flexible and easier to manage (but slower to execute) by using the "famous" PREV trick:

Code:

prd:=Input("Periods",1,1000,21);

dr:= ROC(C,1,$)/Mov(C,2,S);
vola:= Stdev(dr, prd);

{plot}
Sum(vola<=LastValue(vola+PREV*0),prd)/prd;



wabbit [:D]

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.