Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi MetaReader
The formula below no longer has any Cum() functions. Cum(1) has been replaced by the new C1 variable C1:=BarsSince(IsUndefined(Ref(C,-1)))+1; However it is not so easy to eliminate the remaining 4 Cum() functions. My quick solution probably won't run in FinTrader and more tha Cum() will, so there's potentially still a problem to be solved. The MetaStock solution for non-contiguous values is to use the Forum DLL Sum function. This allows a variable lookback period for summing all relevant values from bar one.
There's a distinct possibility that the IsDefined() and IsUndefined() are also absent from FinTrader, and if that's the case your solution is probably as far away as ever.
Here's my revised formula. I hope it helps.
Roy
{Two Trend-lines Wedges Scale from right}
pv:=Input("VeryLong=4,Long=3,Med=2,Short=1",1,4,4); pp:= LastValue(If(pv=4,4,If(pv=3,2,If(pv=2,1,0.5)))); C1:=BarsSince(IsUndefined(Ref(C,-1)))+1; r0:=If(MP()>=Ref(MP(),-1),ATR(1),0); r1:= Log(If(r0>0,ATR(1),H)/H); d:=ExtFml("Forum.SUM",r0>0,C1); r2:=ExtFml("Forum.SUM",r1,C1)/(d+(d=0)); r3:=LastValue(100*Exp(LastValue(r2)))*pp; r4:=LastValue(PeakBars(2,H,r3))-LastValue(PeakBars(1,H,r3)); r5:=(LastValue(Peak(1,H,r3))-LastValue(Peak(2, H,r3)))/r4; {slope} r6:=LastValue(Peak(2,H,r3))+ (r5*(C1-LastValue(C1-PeakBars(2,H,r3)))); r7:=If(C1<LastValue(C1-PeakBars(2,H,r3)),BarsSince(C1>=LastValue(C1-PeakBars( 2,H,r3))),r6); s0:= If(MP()<=Ref(MP(),-1),ATR(1),0); s1:= Log(If(s0>0,ATR(1),L)/L); d:=ExtFml("Forum.SUM",s0>0,C1); s2:=ExtFml("Forum.SUM",s1,C1)/(d+(d=0)); s3:= LastValue(100*Exp(LastValue(s2)))*pp; s4:=LastValue(TroughBars(2,L,s3))-LastValue(TroughBars(1,L,s3)); s5:= (LastValue(Trough(1,L,s3))-LastValue(Trough(2,L,s3)))/s4; {slope} s6:=LastValue(Trough(2,L,s3))+ (s5*(C1-LastValue(C1-TroughBars(2,L,s3)))); s7:=If(C1<LastValue(C1-TroughBars(2,L,s3)),BarsSince(C1>=LastValue(C1-TroughBars(2,L,s3))),s6); r7; s7;
|