logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
uasish  
#1 Posted : Sunday, June 11, 2006 3:21:23 AM(UTC)
uasish

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/13/2005(UTC)
Posts: 170

Thanks: 7 times
Dear Sir, To put Roy's weekly (dynamic) close on EOD data i need the formula of PDI & MDI (to put the close).Next i have 3 conditions and three has to be valid for which i need Wabbit's method of using the Alert function (i have lost it) hence any of his code using that will help me. Regards Asish
mstt  
#2 Posted : Sunday, June 11, 2006 3:58:57 AM(UTC)
mstt

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)
Asish PlusDI and MinusDI (DI+ and DI- from the pulldown menu) can also be derived from the Weekly ADX formula. Note the added outputs of Round(I) and Round(M) in the following formula which give these as weeky results on EOD charts. These are the equivalent of the standard MetaStock PDI() and MDI() functions. My weekly formula is based on the second formula which was originally published by Equis. Note that neither my weekly formula nor the Equis formula on which it is based contain the Round() function (as published). It is the inclusion of Round() that brings PlusDI and MinusDI outputs into conformity with the standard MetaStock PDI() and MDI() functions. Sorry but I can't help you with Wabbit's Alert() code. Roy MetaStock Tips & Tools PS Improving the initial accuracy of the Weekly ADX indicator is a project that has been on the back-burner for some time. Who knows, maybe I'll even get it done one day soon. {Weekly ADX} {2004 Roy Larsen, rlarsen@man.quik.co.nz} {for use on daily charts with Jose Silva's "Calendar Week counter"} N:=Input("Weekly ADX Periods",1,99,14); X:=1/N; Q:=Input("Display Mode, 0=Static 1=Dynamic 2=Test",0,2,1); {0=Display, update on Friday when possible} {1=Display, update on each new bar} {2=Backtest, update on first bar of new week} G:=LastValue(Highest(Sum(DayOfWeek()=5,5))=5); I:=Fml("Calendar Week counter"); I:=Abs(I-ValueWhen(2-G,1,I)); M:=G OR I>0; F:=G OR (DayOfWeek()=5 AND I=0); A:=LastValue(Cum(1)-1)=Cum(1); B:=Alert(A,2)*(A=0); J:=If(F,1,If(Alert(F,2)=0 AND M,2,0)); J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J); J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J)); Ho:=HighestSince(1,M,H); Ho:=ValueWhen(1,J,If(J=1,Ho,ValueWhen(2-G,1,Ho))); Lo:=LowestSince(1,M,L); Lo:=ValueWhen(1,J,If(J=1,Lo,ValueWhen(2-G,1,Lo))); Ci:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C))); Ho:=ValueWhen(1,Ho>0,Ho); Hi:=ValueWhen(2,J,Ho); Lo:=ValueWhen(1,Lo>0,Lo); Li:=ValueWhen(2,J,Lo); Ci:=ValueWhen(1,Ci>0,Ci); Ci:=ValueWhen(2,J,Ci); Pdm:=If(Ho>Hi AND Lo>=Li,Ho-Hi,If(Ho>Hi AND Lo<Li AND (Ho-Hi)>(Li-Lo),Ho-Hi,0)); Mdm:=If(Lo<Li AND Ho<=Hi,Li-Lo,If(Ho>Hi AND Lo<Li AND (Ho-Hi)<(Li-Lo),Li-Lo,0)); R:=Max(Max(Abs(Ci-Lo),Abs(Ci-Ho)),Ho-Lo); A:=If(Cum(J>0)<N+1,Cum((J>0)*R)/N, ValueWhen(1,J,PREV)*(1-X)+R*X); I:=If(Cum(J>0)<N+1,Cum((J>0)*Pdm)/N, ValueWhen(1,J,PREV)*(1-X)+Pdm*X); I:=(100*I/A); {**}Round(I); M:=If(Cum(J>0)<N+1,Cum((J>0)*Mdm)/N, ValueWhen(1,J,PREV)*(1-X)+Mdm*X); M:=(100*M/A); {**}Round(M); M:=Abs(I-M)/(I+M); F:=ValueWhen(1,J,PREV)*(1-X)+M*X; X:=100*If(ValueWhen(N+1,J,F)>0,F,F); {MetaStock code written by Equis and published in the Oct99 TASC} {ADX Raw} Periods:=Input("Enter time periods",1,100,14); PlusDM:=If(H>Ref(H,-1) AND L>=Ref(L,-1),H-Ref(H,-1), If(H>Ref(H,-1) AND L<Ref(L,-1) AND H-Ref(H,-1)>Ref(L,-1)-L, H-Ref(H,-1),0)); DIPlus:=100*Wilders(PlusDM,Periods)/ATR(Periods); MinusDM:=If(L<Ref(L,-1) AND H<=Ref(H,-1),Ref(L,-1)-L, If(H>Ref(H,-1) AND L<Ref(L,-1) AND H-Ref(H,-1)<Ref(L,-1)-L, Ref(L,-1)-L,0)); DIMinus:=100*Wilders(MinusDM,Periods)/ ATR(Periods); DIDif:=Abs(DIPlus - DIMinus); DISum:=DIPlus + DIMinus; 100*Wilders(DIDif/DISum,Periods); X;
uasish  
#3 Posted : Sunday, June 11, 2006 5:46:01 AM(UTC)
uasish

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/13/2005(UTC)
Posts: 170

Thanks: 7 times
Respected Roy, Thank you.Frankly didnt expect such quick response. Regards Asish
yasmina9  
#4 Posted : Sunday, October 14, 2007 12:50:10 PM(UTC)
yasmina9

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 10/14/2007(UTC)
Posts: 1

Hi Roy,

I have followed your advice and by derivation try to remake DI+ and DI- from your formula but without success. Well, the results are sometimes very close with the metastock result in weekly but in big market movement, the spread can be huge. May you help me. JP

Tomtep  
#5 Posted : Wednesday, November 10, 2010 3:51:24 AM(UTC)
Tomtep

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/27/2009(UTC)
Posts: 4

Dear mstt, I want to build a explorer with conditions: PDI(weekly)>MDI(weekly) and ADX(weekly)>25 depend on your indicator. I use: FmlVar("Weekly ADX","PDM") >FmlVar("Weekly ADX","MDM") and FmlVar("Weekly ADX","X") >25 but the result's wrong. Please let me know how to call DI+,DI- and ADX value. Thank so much!
mstt  
#6 Posted : Wednesday, November 10, 2010 2:47:40 PM(UTC)
mstt

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 Tomtep There are several reasons why your use of the Weekly ADX indicator does not return the results you expect. Most importanly, are you loading enough data for the Weekly ADX indicator to generate correct values? For a 10-Period ADX etc I'd suggest 400-500 EOD bars might be necessary to get accurate results. Two other factors to consider are that the standard ADX(), MDI() and PDI() functions provide rounded results, my Weekly ADX does not round results for any or those values. Having said thatYou can round the DIP (PDI) and DIM (MDI) within the exploration - see below. Not only does the standard MetaStock ADX() function round results but the results become less accurate as the Periods value increases. Try plotting both formulas shown in my first response in this thread with a Periods value of 50 on a weekly chart and you'll see the problem of inaccuracy very clearly. The rounding that the MS ADX() function uses is not as easy to decipher as it is for MDI() and PDI() so I've made no effort to allign weekly or Multi-Frame results with the standard ADX function. As I've already pointed out the discrete code version of ADX is more accurate than ADX() anyway so why try to emulate a result that is already suspect? Using the "Multi-Frame D ADX Forum" indicator, here's how to create the exploration. You'll need to set the Periods Parameter for the indicator as needed. Ideally your exploration should be run over the weekend - the weekly value will only update when Friday (end-of-week) data is available. {colA} DIP:=FmlVar("Multi-Frame D ADX Forum","DIP"); DIM:=FmlVar("Multi-Frame D ADX Forum","DIM"); WDX:=Fml("Multi-Frame D ADX Forum"); Rnd(DIP)>Rnd(DIM) AND WDX>25; {filter} colA; Remember, there will be differences between "Multi-Frame D ADX Forum" and ADX(). Check out the differences by plotting both on several years of weekly data. I'm assuming that you also include code for daily conditions in your exploration. If not then it would be simpler to use standard MS functions with the exploration set to weekly. {Multi-Frame D ADX Forum} {Requires Equis Forum DLL} {Roy Larsen, 2008-2010, 11/11/10} {User settings} N:=Input("Multi-Frame D ADX Forum, Periods",1,99,10); J:=Input("Months per Frame, 0=Weekly",0,12,0); J:=If(5>J OR Mod(J,3)=0 AND (J>9 OR 9>J),Int(J),-1); G:=Input("End-of-week Offset in Days",0,6,0); Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,0); {Update on last bar, new bar or new frame} {Timing} {Day count by metastocktools.com} D:=DayOfWeek();M:=Month();Y:=Year(); Z:=Cum(1); F:=Rnd(Life(291231)); M:=If(J=0,ValueWhen(1,Z=1,F+D-G-1)-F, (Y-ValueWhen(1,Z=1,Y))*12+M); I:=If(J=0,Int(M/7),Int((M-1)/Max(1,J))); I:=I>ValueWhen(2,1,I); G:=LastValue(0>J OR Lowest(Sum(I>0,5))=5); I:=ExtFml("Forum.Sum",I,1);M:=G+I; F:=ExtFml("Forum.Sum",Ref(I,1),1)*(M=0)*(Z>1)+G; B:=LastValue(Z);A:=B-1=Z;B:=B=Z; F:=F+B*(Q=0)*(J=0)*(D=5); J:=If(F,1,(Alert(F,2)=0)*M*2*(Z>1)); J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J); J:=If(G,1,If(Q=2,M*2,J)); {Frame prices} B:=HighestSince(1,M+(Z=1),H); Y:=LowestSince(1,M+(Z=1),L); B:=ValueWhen(1,J,If(J=1,B,ValueWhen(2-G,1,B))); {H} Y:=ValueWhen(1,J,If(J=1,Y,ValueWhen(2-G,1,Y))); {L} K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C))); {C} Bi:=ValueWhen(2,J,B); Yi:=ValueWhen(2,J,Y); Ki:=ValueWhen(2,J,K); J:=J>0; I:=Cum(J); {Building ADX} {ATR} A:=Max(Max(Abs(Ki-Y),Abs(Ki-B)),B-Y); M:=Cum(J*A)/Min(I,N); K:=If(N>I,M,A); R:=If(J,If(N>I,1,2*N-1),Pwr(10,10)); A:=ExtFml("Forum.Mov",K,R,E); {DIPlus} D:=If(B>Bi AND Y>=Yi,B-Bi,If(B>Bi AND Yi>Y AND (B-Bi)>(Yi-Y),B-Bi,0)); M:=Cum(J*D)/Min(I,N); K:=If(N>I,M,D); DIP:=100*ExtFml("Forum.Mov",K,R,E)/(A+(A=0)); {DIMinus} B:=If(Yi>Y AND Bi>=B,Yi-Y,If(B>Bi AND Yi>Y AND (Yi-Y)>(B-Bi),Yi-Y,0)); M:=Cum(J*B)/Min(I,N); K:=If(N>I,M,B); DIM:=100*ExtFml("Forum.Mov",K,R,E)/(A+(A=0)); {ADX} X:=Abs(DIP-DIM)/(DIP+DIM+(DIP+DIM=0)); M:=Cum(J*X)/Min(I,N); K:=If(N>I,M,X); X:=100*ExtFml("MSTT.EMA",K,R); ValueWhen(1,I>=2*N,X); Roy PS: This indicator has been modified in order to post correctly. If it causes problems I can email you the original.
Tomtep  
#7 Posted : Wednesday, November 10, 2010 11:32:33 PM(UTC)
Tomtep

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/27/2009(UTC)
Posts: 4

Dear mstt, Thank you for your quickly reply, I have trouble with your new indicator: "This DLL does not exist in the MSX DLL folder.". I think that I miss 1 ddl file in order to call ExtFml("MSTT.EMA",K,R) function Thanks,
mstt  
#8 Posted : Thursday, November 11, 2010 12:52:37 PM(UTC)
mstt

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 Tomtep My mistake - I forgot to change one line of code so that the MSTT DLL wouldn't be needed. Change the offending line from ... X:=100*ExtFml("MSTT.EMA",K,R); to ... X:=100*ExtFml("Forum.Mov",K,R,E); Roy
Tomtep  
#9 Posted : Thursday, November 11, 2010 9:27:40 PM(UTC)
Tomtep

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/27/2009(UTC)
Posts: 4

Dear mstt, Thank for your help, this explorer works like a champ. It has only 1 small problem: some scurities in the result from yours is not match with DI, and ADX weekly explorer original of equis.
mstt  
#10 Posted : Friday, November 12, 2010 1:50:13 AM(UTC)
mstt

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 Tomtep Well there will be a reason for any variations that you discover. I've already mentioned some of them, and none of the other reasons that I can think of reflect badly on the "ADX Raw" indicator that I've used as a model. In other words I'm quite certain that any anomalies have a valid explanation and do not warrant an attempt to "fix" my code. If I thought that that was the appropriate response I'd be asking for a whole lot more information than has been provided so far. There are a number of things that you can do to solve perceived issues, and for that you need a thorough understanding of MFL, the ability to make comparisons between indicators and/or MS functions, and be able to draw logical conclusions from your observations. Having me do the donkey work for you is not really going to help either of us, so make the most of this opportunity to learn why "things MetaStock" don't always deliver the results you expect. Roy
Tomtep  
#11 Posted : Tuesday, November 16, 2010 9:16:18 PM(UTC)
Tomtep

Rank: Newbie

Groups: Registered, Registered Users
Joined: 12/27/2009(UTC)
Posts: 4

Thank Roy;)
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.