DIMinus / DIPlus Calculation
Author: mr_fast
Creation Date: 2/14/2019 10:18 AM
profile picture

mr_fast

#1
Hello!
I use WealthLab Pro to develop, test and optimize strategies. I trade with another program (Tradematic). And in these programs, the indicators ADX, DX, DIMinus, DIPlus do not match. Began to understand what is the reason for this discrepancy. It turned out that the difference is present in the calculation of the indicators DIMinus and DIPlus. I tried to create my own version of the indicators based on the descriptions in the WealthLab Wiki, but I could not create indicators that coincide with those built into the WealthLab Pro.
I ask you to show the part of the code that calculates -DM and + DM according to your scheme:
1. For uptrending days, -DM = zero
2. For downtrending days, -DM = yesterday's low - today's low
3. For inside days, -DM = zero
4. For outside days, if yesterday's low - today's low, is greater than today's high- yesterday's high, then -MD = yesterday's low - today's low, otherwise -DM = zero
5. For upwards gap days, -DM = zero
6. For downwards gap days, -DM = yesterday's low - today's low
Thanks!
profile picture

Eugene

#2
Hi,

There really is no point for this duplicate thread as all I can say could be found in these (and other) forum topics:

Trying to match DI +/- (ADX) to my Excel formula, refer to post #4 for your "show me the code" question
Difference between WLP ADX & ATP ADX

There's no doubt that WL's formulas are correct and stand the test of time (about 2 decades). Probably your platform or own code applies an unconventional smoothing (not WilderMA) or something like that.
profile picture

mr_fast

#3
I wrote my code calculation according to WealthLab Wiki.
Please indicate where I have my differences with your calculations.
CODE:
Please log in to see this code.
profile picture

Eugene

#4
I didn't review your code but your usage of SMA just strikes the eye. As we repeatedly noted in replies to similar questions before and as can be proven by KGo's post #6 in this topic, Wilder's indicators use WilderMA smoothing.

Re: Math.Abs in your code. For your convenience, WealthScript includes DataSeries.Abs which together with the bitwise shift operator >> should provide a nice syntactic sugar and a replacement for lines like:
CODE:
Please log in to see this code.
profile picture

mr_fast

#5
I tried using WilderMA smoothing, but my indicator but still does not match with yours. Concluded that the difference precisely in calculations and calculation logic DMinus and DMPlus.
profile picture

Eugene

#6
Keep in mind that all of those indicators (ADX, DI+/DI-, WilderMA...) are unstable as per the WS Programming Guide (Indicators > Stability of Indicators). You have to load at least 3-4 times bars * the indicator period before making a comparison but preferably more. Same applies to your other platform (and in general to any other product for this matter).

Other posters seem to have matched our calculations using provided formulas. Good luck with your project.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).