Merhabalar,
Aşağıdaki şekilde deneyiniz,
pds:=Input("average trend length periods",2,252,21);
pr:=Input("Open=1 High=2 Low=3 Close=4 Vol=5 MP=6, P=7",1,7,4);
display:=Input("plot Trend line = 1, Trend points = 2",1,2,1);
{define events}
pr1:=If(pr=1,O,If(pr=2,H,If(pr=3,L,If(pr=5,V,If(pr=6,MP(),If(pr=7,P,C))))));
price1:=pr1;
price2:=pr1;
time1:=price1>Ref(HHV(price1,pds),-1);
time2:=price2<Ref(LLV(price2,pds),-1);
time11:=time1 AND Cum(time1)=LastValue(Cum(time1));
time22:=time2 AND Cum(time2)=LastValue(Cum(time2));
{sort events}
t1pds:=LastValue(BarsSince(time11));
t2pds:=LastValue(BarsSince(time22));
x1:=If(t1pds>=t2pds,time11,time22);
x2:=If(t1pds>=t2pds,time22,time11);
y1:=If(t1pds>=t2pds,price1,price2);
y2:=If(t1pds>=t2pds,price2,price1);
{fix coordinates}
y11:=ValueWhen(1,x1,y1);
y22:=LastValue(ValueWhen(1,x2,y2));
b1:=LastValue(BarsSince(x1));
b2:=LastValue(BarsSince(x2));
plot:=y11+BarsSince(x1)*(y22-y11)/(b1-b2);
If(display=1,plot,time1+time2)
iyi çalışmalar