MetaStock™ Zone Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

 A B C D E F G H I J K L M N O P R S T U V W Y Z #

Trend Resistance Line / Channel

The indicator below plots a resistance line from 2 highs (peaks) and plots a channel from
a low (trough) between the two peaks. Indicator is period based.

How do you modify this indicator to plot a Support line from two lows (troughs) a parallel channel line from a high (peak)?

I've understood only part of the code (till the calculation of slope).

arun

Trend Resistance Line / Channel

pds:=Input("Lookback Periods",2,100,5);
hic:= H>Ref(HHV(H,pds),-1) AND H>=Ref(HHV(H,pds),pds);
y1t:=LastValue(ValueWhen( 2, hic=1, H ));
y2t:=LastValue(ValueWhen( 1, hic=1, H ));
x1t:=LastValue(ValueWhen( 2, hic=1 , Cum(1) ));
x2t:=LastValue(ValueWhen( 1, hic=1 , Cum(1) )); {at:=(y1t-y2t)/(x1t-x2t);bt:=y1t-at*x1t;}
yt:=(y1t-y2t)/(x1t-x2t)*Cum(1)+y1t-(y1t-y2t)/(x1t-x2t)*x1t;
{yt:=at*cum(1)+bt;}
e1:=H-yt; ret1:=LastValue(Cum(1)-(x1t+Int((x2t-x1t)/2)-1));
seg1:=LastValue(Int((x2t-x1t)/2+Int(2*pds/5)){+pds-1});
x1:=LastValue(Cum(1)-HHVBars(Ref(e1,-ret1),seg1)-ret1);
y1:=LastValue(ValueWhen(1,x1=Cum(1),H));
ret2:=LastValue(Cum(1)-(x2t+Int(4*pds/5)));
seg2:=LastValue(Int((x2t-x1t)/2)+Int(4*pds/5));
x2:=LastValue(Cum(1)-HHVBars(Ref(e1,-ret2),seg2)-ret2);
y2:=LastValue(ValueWhen(1,x2=Cum(1),H)); {a:=(y1-y2)/(x1-x2);b:=y1-a*x1;}
a:=(y1-y2)/(x1-x2);
HiTL;
HiTL-decal

Source / From: TOP
[EquisMetaStock Group]

Equis and MetaStock® and MetaStock Professional® are registered trademarks of Equis International. Achelis Binary Wave®, The DownLoader®,
Expert Advisor®, OptionScope®, Quotecenter® and Smart Charts® are trademarks of Equis International, a Thomson Reuters company.