Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 4/1/2006(UTC) Posts: 135 Location: Romania
|
a:=If(Cross(H,ValueWhen(1,If(C>Mov(C,50,S),1,0)=1 AND Ref(If(C>Mov(C,50,S),1,0)=1,-1)=0,H)) AND BarsSince(If(C>Mov(C,50,S),1,0)=1 AND Ref(If(C>Mov(C,50,S),1,0)=1,-1)=0)<BarsSince(If(C>Mov(C,50,S),1,0)=0 AND Ref(If(C>Mov(C,50,S),1,0)=1,-1)=1) AND BarsSince(If(C>Mov(C,50,S),1,0)=1 AND Ref(If(C>Mov(C,50,S),1,0)=1,-1)=0)<=30,1,0); b:=If(Cross(C,Mov(C,50,S)) AND Ref(BarsSince(Cross(C,Mov(C,50,S))),-1)>30,Cum(1),0); If(ValueWhen(1,a=1,ValueWhen(1,b<>0 AND Ref(b,-1)=0,b))=ValueWhen(2,a=1,ValueWhen(1,b<>0 AND Ref(b,-1)=0,b)),0,a)
try this it might help; what i don`t know if what if there are a lot of crossovers one after another at intervals smaler than 30 bars? u want a signal after each crossover even if u have one after the previous crossover and there isn`t 30 bars since then?
the code above will ignore any crossover that happened at less than 30 since the previous one (hopefully)
the code bellow wil plot 1 after each crossover even if there is less than 30 from the previous one:
a:=If(Cross(H,ValueWhen(1,If(C>Mov(C,50,S),1,0)=1 AND Ref(If(C>Mov(C,50,S),1,0)=1,-1)=0,H)) AND BarsSince(If(C>Mov(C,50,S),1,0)=1 AND Ref(If(C>Mov(C,50,S),1,0)=1,-1)=0)<BarsSince(If(C>Mov(C,50,S),1,0)=0 AND Ref(If(C>Mov(C,50,S),1,0)=1,-1)=1) AND BarsSince(If(C>Mov(C,50,S),1,0)=1 AND Ref(If(C>Mov(C,50,S),1,0)=1,-1)=0)<=30,1,0); b:=If(Cross(C,Mov(C,50,S)),Cum(1),0);
If(ValueWhen(1,a=1,ValueWhen(1,b<>0 AND Ref(b,-1)=0,b))=ValueWhen(2,a=1,ValueWhen(1,b<>0 AND Ref(b,-1)=0,b)),0,a)
i hope that helps; i did not verified the code so i hope it is what u want if not i don`t have another ideea now, tell me if it works
|