Hm, there's something weird about this function. I've double checked it with two NinjaTrader ADXVMA indicators from the forum here, but although the code from NinjaTrader and MultiCharts is the same, the results are wildly different:
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).
Anyone knows what can cause this difference?
Little update February 16th:
Though Mike coded the function correctly (thanks Mike ) and my converted function works the same, the code from the NinjaTrader indicator is somewhat sloppy and I wouldn't be surprised if NinjaTrader used some other calculation method than MultiCharts.
There are some 'weird' things in the code, like using the constant i value of 0 for serializing (what's the point of that?), or code like:
I don't see the point in setting the value of Out twice this way, but that's perhaps that due to me not using NinjaTrader extensively.
Perhaps I made a mistake, and by the way, I'm not saying that the MultiCharts function cannot be used or gives wrong signals. Just that the results are different from the NinjaTrader version.
Last edited by Jura; February 16th, 2012 at 02:27 AM.
The following 6 users say Thank You to Jura for this post:
I have revisited the NinjaTrader code for the ADXVMA, and found it extremely dirty with a number of bugs and inconsistencies. As somebody wanted to use it, I took the challenge to clean it up. I am posting the code here,
- because the Easy Language version is already much cleaner than all NinjaTrader versions
- because it helps to understand what the indicator actually does
Here is the code. k is a smoothing constant of an exponential moving average based on Wilder's average ( that is the 1/n method as opposed to the 2/(n+1) method later used as a result of the assimilation between SMA and EMA). The various periods ADXperiod, weight DX etc. are replaced with a single period. The useless parameter i is dropped (as for the MultiCharts version). Double variables are not compared to zero but to the value double.Epsilon to take into account the error term. For the initialization of the first value for the ADXVMA 0 has been replaced with Input(0). The version now allows for calculating the ADXVMA from other values than the Close series.
Clean code for comparison with the Easy Language version is here:
ADX is a strength of direction indicator. It does not indicate direction. Typically it is used to determine whether a breakout is valid, or the converse, that a break may be about to occur because of the lack of directional strength.