| 
Rank: Advanced Member
 Groups: Moderators, Registered, Registered Users, SubscribersJoined: 10/8/2010(UTC)
 Posts: 1,999
 
 Thanks: 96 timesWas thanked: 160 time(s) in 155 post(s)
 
 | 
            
	      
                Barbara Star’s article, “Stay On Track With The Supertrend Indicator,” provided her calculation method of this popular indicator. Here is the formula to add that indicator to MetaStock. 
 The Supertrend Indicator: Code:{Supertrend Indicator}
a1:= Input("Number of periods in ATR",2,100,10);
a2:= Input("Multiplier for ATR",1,10,3);
dis:= a2 * ATR(a1);
bTop:= MP() + dis;
bBot:= MP() - dis;
Top:= If( (bTop < PREV) OR (Ref(C, -1)) > PREV, bTop, PREV);
Bot:= If( (bBot > PREV) OR (Ref(C, -1)) < PREV, bBot, PREV);
sti:= If( PREV = Ref(top,-1),
If( C<=Top, Top, Bot),
If( PREV = Ref(bot,-1),
If( C>= Bot, Bot, Top), top));
sti
 |