Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/29/2004(UTC) Posts: 1,394 Location: Glastonbury, CT
Was thanked: 2 time(s) in 2 post(s)
|
Here is my version for both buy and sell
LL:=If(L=LLV(L,5),L,If(Ref(L,-1)=LLV(L,5),Ref(L,-1),If(Ref(L,-2)=LLV(L,5),Ref(L,-2),If(Ref(L,-3)=LLV(L,5),Ref(L,-3),If(Ref(L,-4)=LLV(L,5),Ref(L,-4),0)))));
HH:=If(H=HHV(H,5),H,If(Ref(H,-1)=HHV(H,5),Ref(H,-1),If(Ref(H,-2)=HHV(H,5),Ref(H,-2),If(Ref(H,-3)=HHV(H,5),Ref(H,-3),If(Ref(H,-4)=HHV(H,5),Ref(H,-4),0)))));
NH:=ValueWhen(1,H>Ref(HHV(H,5),-1),H);
NL:=ValueWhen(1,L<Ref(LLV(L,5),-1),L);
Set1:=HHV(H,3)<HHV(H,4);
Set2:=LLV(L,3)>LLV(L,4);
Val1:=ValueWhen(1,BarsSince(H>Ref(HHV(H,5),-1))=3 AND Set1=true,NH);
Val2:=ValueWhen(1,BarsSince(L<Ref(LLV(L,5),-1))=3 AND Set2=true,NL);
Val3:=ValueWhen(1,BarsSince(H>Ref(HHV(H,5),-1))=3 AND Set1=true,LL);
Val4:=ValueWhen(1,BarsSince(L<Ref(LLV(L,5),-1))=3 AND Set2=true,HH);
Per1:=Input("max length",10,100,30);
RWH:=(H-Ref(L,-Per1))/(ATR(Per1)*Sqrt(Per1));
RWL:=(Ref(H,-Per1)-L)/(ATR(Per1)*Sqrt(Per1));
Pk:=Mov((RWH-RWL),3,W);
TB:=If(Pk>0,Val1,Val4);
BB:=If(Pk>0,Val3,Val2);
TB;BB;
Here is the original version for long
LL:=If(L=LLV(L,5),L,If(Ref(L,-1)=LLV(L,5),Ref(L,-1),If(Ref(L,-2)=LLV(L,5),Ref(L,-2),If(Ref(L,-3)=LLV(L,5),Ref(L,-3),If(Ref(L,-4)=LLV(L,5),Ref(L,-4),0)))));
NH:=ValueWhen(1,H>Ref(HHV(H,5),-1),H);
Set1:=HHV(H,3)<HHV(H,4);
Val1:=ValueWhen(1,BarsSince(H>Ref(HHV(H,5),-1))=3 AND Set1=true,NH);
Val2:=ValueWhen(1,BarsSince(H>Ref(HHV(H,5),-1))=3 AND Set1=true,LL);
TB:=Val1;
BB:=Val2;
TB;BB;
|