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)
|
factor:=Input("Time Factor", 0, 1000, 1);
Trendfactor:=Input("Trend Factor", 0, 1000, 2);
offset:=Input("Offset", 0, 1000, 0);
TD:=ExtFml("PowerPivots.TrendDirection",1,TrendFactor);
HD:=ExtFml("PowerPivots.TDataCreate",1, factor);
LD:=ExtFml("PowerPivots.TDataCreate",2, factor);
LL:=If(LD=LLV(LD,5),LD,If(Ref(LD,-1)=LLV(LD,5),Ref(LD,-1),If(Ref(LD,-2)=LLV(LD,5),Ref(LD,-2),If(Ref(LD,-3)=LLV(LD,5),Ref(LD,-3),If(Ref(LD,-4)=LLV(LD,5),Ref(LD,-4),0)))));
HH:=If(HD=HHV(HD,5),HD,If(Ref(HD,-1)=HHV(HD,5),Ref(HD,-1),If(Ref(HD,-2)=HHV(HD,5),Ref(HD,-2),If(Ref(HD,-3)=HHV(HD,5),Ref(HD,-3),If(Ref(HD,-4)=HHV(HD,5),Ref(HD,-4),0)))));
NH:=ValueWhen(1,HD>Ref(HHV(HD,5),-1),HD);
NL:=ValueWhen(1,LD<Ref(LLV(LD,5),-1),LD);
Set1:=HHV(HD,3)<HHV(HD,4);
Set2:=LLV(LD,3)>LLV(LD,4);
Val1:=ValueWhen(1,BarsSince(HD>Ref(HHV(HD,5),-1))=3 AND Set1=true,NH);
Val2:=ValueWhen(1,BarsSince(LD<Ref(LLV(LD,5),-1))=3 AND Set2=true,NL);
Val3:=ValueWhen(1,BarsSince(HD>Ref(HHV(HD,5),-1))=3 AND Set1=true,LL);
Val4:=ValueWhen(1,BarsSince(LD<Ref(LLV(LD,5),-1))=3 AND Set2=true,HH);
TB:=If(Sum(TD>0,2)>1,Val1,Val4);
BB:=If(Sum(TD>0,2)>1,Val3,Val2);
TB:=ExtFml("PowerPivots.TDataLocalize",TB, factor, offset);
BB:=ExtFml("PowerPivots.TDataLocalize",BB, factor, offset);
TB;BB;
just make sure That trend factor is greater than Time factor
|