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, April 11, 2024 7:59:18 PM(UTC)
MS Support

Rank: Advanced Member

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

Thanks: 91 times
Was thanked: 155 time(s) in 150 post(s)

Alfred Francois’ article, “Trend Identification by Price and Time Filtering”, introduced his Price-Time Filtering indicator. Here are three formulas to add that indicator to MetaStock. 

Price & Time Filter (Monthly on Daily):

Code:
{a monthly Price & Time Filter calculated on daily data}
{expects to be plotted on a daily chart}
new:= ROC(DayOfMonth(),1,$)<1;
mhi:= HighestSince(1, new, H);
mlo:= LowestSince(1, new, L);
up:= new AND C > Ref(mhi, -1);
dn:= new AND C < Ref(mlo, -1);
trend:= If( up, Max(1, PREV+1), If(dn, Min(-1, PREV-1), 
If(new, If(PREV>0, PREV+1, PREV-1), PREV)));
If(trend>0, trend, 0);
If(trend<0, trend, 0)

Price & Time Filter (Weekly on Daily):

Code:
{a weekly Price & Time Filter calculated on daily data}
{expects to be plotted on a daily chart}
fri:= DayOfWeek() = 5;
new:= ROC(DayOfWeek(),1,$)<1;
recalc:= fri OR (new AND Ref(fri=0, -1));
hi:= HighestSince(1, new, H);
lo:= LowestSince(1, new, L);
whi:= If(fri, hi, Ref(hi, -1));
wlo:= If(fri, lo, Ref(lo, -1));
up:= recalc AND C > Ref(whi, -1);
dn:= recalc AND C < Ref(wlo, -1);
trend:= If( up, Max(1, PREV+1), If(dn, Min(-1, PREV-1), 
If(recalc, If(PREV>0, PREV+1, PREV-1), PREV)));
If(trend>0, trend, 0);
If(trend<0, trend, 0)

Price & Time Filter (native):

Code:
{calculates the Price & Time Filter on the data interval of the chart}
up:= C > Ref(H, -1);
dn:= C < Ref(L, -1);
trend:= If( up, Max(1, PREV+1), If(dn, Min(-1, PREV-1), If(PREV>0, PREV+1, PREV-1)));
If(trend>0, trend, 0);
If(trend<0, trend, 0)

Users browsing this topic
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.