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

Notification

Icon
Error

Options
Go to last post Go to first unread
gorachand  
#1 Posted : Thursday, July 20, 2023 4:27:14 PM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 103

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Could somebody give me a code for a custom adx indicator where you can change at will both adx periods and DI length. This option is given in Tradingview but I want the code for Metastock
MS Support  
#2 Posted : Monday, July 24, 2023 4:51:21 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,934

Thanks: 85 times
Was thanked: 154 time(s) in 150 post(s)

Originally Posted by: gorachand Go to Quoted Post
Could somebody give me a code for a custom adx indicator where you can change at will both adx periods and DI length. This option is given in Tradingview but I want the code for Metastock

Hello,

I am not sure if this is exactly what you're looking for but there is a Custom ADX that you can create in the Indicator Builder, at https://www.metastock.com/customer/resources/formulas/?id=3 (which could also be potentially modified if this does not meet your exact needs).

gorachand  
#3 Posted : Monday, July 24, 2023 6:20:34 PM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 103

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Hello MS Support, Thank you for your reply. I had a look at the adx custom code. However the variable I am interested in is DI length. I will rephrase my question. Could you give me the code for an adx indicator where thd adx period is 8 and the DI length is 13?
MS Support  
#4 Posted : Tuesday, July 25, 2023 2:42:04 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,934

Thanks: 85 times
Was thanked: 154 time(s) in 150 post(s)

Originally Posted by: gorachand Go to Quoted Post
Hello MS Support, Thank you for your reply. I had a look at the adx custom code. However the variable I am interested in is DI length. I will rephrase my question. Could you give me the code for an adx indicator where thd adx period is 8 and the DI length is 13?

Hi again,

I'm not too familiar with the inner workings of the ADX, but note that the custom ADX is broken into constituent parts:

Code:
PlusDI:=100*Wilders(PlusDM,Periods)/ATR(Periods);

and

Code:
MinusDI:=100*Wilders(MinusDM,Periods)/ATR(Periods);

and

Code:
ADXFinal:=100*Wilders(DIDif/DISum,Periods);

"Periods" in this case is a variable that is used throughout the custom ADX. However, you do not have to use a common variable. You can substitute any numerical value you like in place of "Periods" in the formula.

This seems to me to mean that you could change the following lines of the formula as follows:

Code:
PlusDI:=100*Wilders(PlusDM,13)/ATR(13);

and

Code:
MinusDI:=100*Wilders(MinusDM,13)/ATR(13);

and

Code:
ADXFinal:=100*Wilders(DIDif/DISum,8);

(You could also comment out or remove the first line of the formula since you would be no longer using the "Periods" variable)

Edited by user Tuesday, July 25, 2023 2:48:29 PM(UTC)  | Reason: Not specified

gorachand  
#5 Posted : Thursday, July 27, 2023 7:09:47 AM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 103

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Thank you MS support-- I will check out your code and get back to you if necessary.
gorachand  
#6 Posted : Thursday, July 27, 2023 3:34:59 PM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 103

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)

Hello MS Support,

       As your code was giving debugging errors----I had to declare the variables.Then the code worked but was giving Negative values of ADX at some points and at points extremely high values--which as you know is unacceptable

Could you please see what's wrong?

PlusDM:=H-Ref(H,-1);

MinusDM:=Ref(L,-1)-L;

PlusDI:= 100*Wilders(PlusDM,13)/ATR(13);

MinusDI:= 100*Wilders(MinusDM,13)/ATR(13);

ADXFinal:= 100*Wilders(PlusDI-MinusDI/PlusDI+MinusDI,8);

ADXFinal;

gorachand  
#7 Posted : Friday, July 28, 2023 3:27:42 AM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 103

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)

Hello MS Support,

   I copied the code for the variables from ADX Custom---and this code works to some extent---but still does not tally with the ADX on TradingView where I put the periods  equal to 8 and DI length equal to 13

Here is the modified code

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));

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));

PlusDI:= 100*Wilders(PlusDM,13)/ATR(13);

MinusDI:= 100*Wilders(MinusDM,13)/ATR(13);

ADXFinal:= Wilders(Abs(PlusDI-MinusDI)/PlusDI+MinusDI,8);

ADXFinal;

MS Support  
#8 Posted : Friday, July 28, 2023 2:33:17 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,934

Thanks: 85 times
Was thanked: 154 time(s) in 150 post(s)
Originally Posted by: gorachand Go to Quoted Post

Hello MS Support,

   I copied the code for the variables from ADX Custom---and this code works to some extent---but still does not tally with the ADX on TradingView where I put the periods  equal to 8 and DI length equal to 13

Here is the modified code

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));

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));

PlusDI:= 100*Wilders(PlusDM,13)/ATR(13);

MinusDI:= 100*Wilders(MinusDM,13)/ATR(13);

ADXFinal:= Wilders(Abs(PlusDI-MinusDI)/PlusDI+MinusDI,8);

ADXFinal;

Hi again,

That looks like it would be the correct modification, but I am not familiar with TradingView's platform. Keep in mind that this MetaStock Custom ADX is slightly different than even the MetaStock built-in ADX in that it keeps the decimal values.

However, if you use the MetaStock Custom ADX with the standard values for all variables, it should generally match the MetaStock built-in ADX with the same setting (i.e. use 14 for the built-in ADX and use 14 for all custom ADX variables) and compare the outputs of both.

After that, I would compare the MetaStock built-in ADX with the TradingView ADX using the same settings. If these don't match, then I would not expect the Custom ADX to match either.

Update: So I did a basic comparison on their site using TSLA with ADX 14 for both variables. There were some differences that could be accounted for by rounding.

When I used your preferred settings (13 for the +/- DI) and 8 for the ADX calculation I got a result of 21.2445 for 7/27/2023 for TSLA.O.

When I used ADX Smoothing 8 and DI length 13 on TradingView for TSLA they show 21.24 which seems pretty comparable.

Edited by user Friday, July 28, 2023 2:48:16 PM(UTC)  | Reason: Not specified

gorachand  
#9 Posted : Tuesday, August 1, 2023 6:39:05 AM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 103

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)

Hello MS Support,

                          I am afraid that the results don't tally. With the modified formula I checked the ADX reading for DABUR.NS for 24th July 2023  and got a reading of 19 while the TradingView result comes to 16.

You can download the screenshots here

https://www.transfernow.net/dl/20230801a9y8PGfT

(Link expires in 7 days)

MS Support  
#10 Posted : Tuesday, August 1, 2023 2:25:15 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,934

Thanks: 85 times
Was thanked: 154 time(s) in 150 post(s)
Originally Posted by: gorachand Go to Quoted Post

Hello MS Support,

                          I am afraid that the results don't tally. With the modified formula I checked the ADX reading for DABUR.NS for 24th July 2023  and got a reading of 19 while the TradingView result comes to 16.

You can download the screenshots here

https://www.transfernow.net/dl/20230801a9y8PGfT

(Link expires in 7 days)

Hello again,

It does not appear that your formula is matching the one from the Custom Formula Collection. In particular, it appears the DIDif and DISum variables were removed. The formula should be as follows:

Code:
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));
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));
PlusDI:=100*Wilders(PlusDM,13)/ATR(13);
MinusDI:=100*Wilders(MinusDM,13)/ATR(13);
DIDif:=Abs(PlusDI-MinusDI);
DISum:=PlusDI+MinusDI;
ADXFinal:=100*Wilders(DIDif/DISum,8);
ADXFinal

gorachand  
#11 Posted : Tuesday, August 1, 2023 2:32:51 PM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 103

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)

I think the indicator is working ok now. Thank you MS Support

thanks 1 user thanked gorachand for this useful post.
MS Support on 8/1/2023(UTC)
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.