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:=If(Cum(1)>x1t-5,(y1-y2)/(x1-x2)*Cum(1)+y1-(y1-y2)/(x1-x2) *x1,BarsSince(Cum(1)>x1t-5)); Diff:=Ref(HiTL-L,-LastValue(Cum(1)-x2t)); decal:=LastValue(HHV(Diff,x2t-x1t));
HiTL;
HiTL-decal

 

Trend Resistance Line / Channel
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.

TradeStation® Pro, TradeStation® 2000i, OptionStation®, SuperCharts®, PowerEditor® and EasyLanguage®
are registered trademarks of TradeStation Technologies, Inc. Other names and marks referred to are the property of their respective owners.

All information provided on this website is for educational purposes only. Trading involves risk, including possible loss of principal and other losses.

Ten i inne materiały na tej stronie zostały zamieszczone zostały jedynie w celach edukacyjnych, nie ponoszę żadnej odpowiedzialno¶ci za ich stosowanie.

Gra na giełdzie i rynkach walutowych (FOREX) niesie ze sob± ryzyko poważnych strat finansowych!