Announcement

Collapse
No announcement yet.

Adx

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adx

    Can anybody help me with this :

    Is it possible to plot DX instead of ADX on the chart?

  • #2
    fankc
    It is possible but it does require writing a script to do that (which is relatively easy).
    The equation to calculate the DX is (100*ABS((DIplus)-(DIminus)))/((DIplus)+(DIminus))
    The first step is to calculate the DIplus and DIminus for which we can use the eSignal builtin functions pdi() and ndi() (see the links for the description and syntax of these functions)
    To do this declare two global variables ie outside of preMain() and main() called DIplus and DIminus and set them initially to null
    PHP Code:
    var DIplus null;
    var 
    DIminus null
    Then inside the main() function first intialize the studies
    PHP Code:
    if(DIplus==nullDIplus pdi(14,14);//replace the parameters with ones of your choice
    if(DIminus==nullDIminus ndi(14,14);//as above 
    then run a null check on the values of the DIplus and DIminus so as to avoid possible divide by 0 errors
    PHP Code:
    if(DIplus.getValue(0)==null || DIminus.getValue(0)==null) return; 
    At this point you have all the components required to calculate the DX. In the equation replace the components with the variables that you have created
    PHP Code:
    var DX = (100 Math.abs((DIplus.getValue(0)) - (DIminus.getValue(0)))) / ((DIplus.getValue(0)) + (DIminus.getValue(0))); 
    All is left to do is to return the value of the DX
    PHP Code:
    return DX
    If you want a ready made template to write the efs see the one provided in this post which includes comments to help you put together the script
    If you encounter any problems post the code as you have written it and I or someone else will be available to assist you
    Alex

    Comment

    Working...
    X