PureBytes Links
Trading Reference Links
|
This should plot an arrow when a close crosses trendline. You'll need to
write your own exit.
Regards,
Ken
-----
Enter Long:
{n=Zig Zag indicator points}
n:=.80{pts};
aPeak:=
Zig(H,n,$)>Ref(Zig(H,n,$),-1) AND
Zig(H,n,$) >Ref(Zig(H,n,$),1{future});
bsp:=BarsSince(aPeak);
bbp:=If(bsp=0,Ref(bsp,-1)+1,bsp);
ppmp:=ValueWhen(2,bsp=0,H)-
ValueWhen(1,bsp=0,H);
ROCbp:=ValueWhen(1,bsp=0,ppmp/bbp);
PeakTrendline:=
If(Ref(bsp,-1)=1 AND aPeak=1,
ValueWhen(1,Ref(bsp,-1)=1,
Ref(H,-2))-bbp*Ref(ROCbp,-1),
If(bsp=1,
ValueWhen(1,bsp=1,Ref(H,-1))-bbp*ROCbp,
ValueWhen(1,bsp=2,Ref(H,-2))-
bbp*Ref(ROCbp,-1)));
Cross(C,PeakTrendline) AND
PeakTrendline<=Ref(PeakTrendline,-1)
AND
{peak locked-in.}
Ref(LowestSince(1,aPeak=1,H),-1)<=
Ref(ValueWhen(1,aPeak=1,H),-1)-n;
====================
====================
Enter Short:
{n=points}
n:=.80{pts};
aTrough:=
Zig(L,n,$)<Ref(Zig(L,n,$),-1) AND
Zig(L,n,$)<Ref(Zig(L,n,$),1{future});
bst:=BarsSince(aTrough);
bbt:=
If(bst=0,Ref(bst,-1)+1,bst);
ptmt:=ValueWhen(2,bst=0,L)-ValueWhen(1,bst=0,L);
ROCbt:=ValueWhen(1,bst=0,ptmt/bbt);
TroughTrendline:=
If(Ref(bst,-1)=1 AND aTrough=1{true},
ValueWhen(1,Ref(bst,-1)=1,
Ref(L,-2))-bst*Ref(ROCbt,-1),
If(bst=1,ValueWhen(1,bst=1,Ref(L,-1))-bst*
ROCbt,ValueWhen(1,bst=2,Ref(L,-2))-bbt*
Ref(ROCbt,-1)));
Cross( TroughTrendline,C) AND
TroughTrendline>=Ref(TroughTrendline,-1)
AND
{trough locked-in}
Ref(HighestSince(1,aTrough=1,L),-1)>=
Ref(ValueWhen(1,aTrough=1,L),-1)+n;
|