Hi all!
I re-wrote the ADX indicator that shows the value of the ADX in the frame on the chart, but sometimes it shows an ADX value that is correct, but sometimes it's wrong.
Could anyone point out where I am making a mistake?
I would appreciate any tips...
Thanks in advance!
Examples Charts
Wrong
Correct
I re-wrote the ADX indicator that shows the value of the ADX in the frame on the chart, but sometimes it shows an ADX value that is correct, but sometimes it's wrong.
Could anyone point out where I am making a mistake?
I would appreciate any tips...
Thanks in advance!
Examples Charts
Wrong
Correct
PHP Code:
/*********************************************************
Alexis C. Montenegro © July 2003
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
**********************************************************/
var vADX = null;
var ADX14;
function preMain() {
setPriceStudy(true);
setStudyTitle("ADX^14");
setDefaultBarFgColor(Color.RGB(255, 0, 255), 0); //adx color
setDefaultBarFgColor(Color.blue, 1); //+DI color
setDefaultBarFgColor(Color.red, 2); //-DI color
setDefaultBarThickness(2,0); //ADX Line thickness
setDefaultBarThickness(1,1); //+DI Line thickness
setDefaultBarThickness(1,2); //-DI Line thickness
setShowTitleParameters(false);
setShowCursorLabel(false);
var fp1 = new FunctionParameter("DILength", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(14); //Edit this value to set a new default
var fp2 = new FunctionParameter("ADXLength", FunctionParameter.NUMBER);
fp2.setLowerLimit(1);
fp2.setDefault(14); //Edit this value to set a new default
}
function main(DILength, ADXLength) {
if (vADX == null) vADX = new ADXDMStudy(DILength, ADXLength);
vADX14 = vADX.getValue(ADXDMStudy.ADX);
if(vADX14 == null)
return;
/******************************************************************
Insert your code following this text block
Use vADX.getValue(ADXDMStudy.ADX) and vADX.getValue(ADXDMStudy.PDI)
and vADX.getValue(ADXDMStudy.NDI) for your code
*******************************************************************/
/*//Display result
drawTextAbsolute( 0, 15, "ADX: " + vADX.getValue(ADXDMStudy.ADX) +" ", Color.black, Color.lightgrey,
Text.BOLD | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, "Arial", 10, "ADX" );*/
// Color Coding
if(vADX.getValue(ADXDMStudy.ADX)>25&&vADX.getValue(ADXDMStudy.ADX)<45&&vADX.getValue(ADXDMStudy.PDI)>vADX.getValue(ADXDMStudy.NDI)){
drawTextAbsolute( 0, 15, "ADX: " + vADX14.toFixed(2) +" ", Color.white, Color.blue,
Text.BOLD | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, "Arial", 10, "ADX" );
}
if(vADX.getValue(ADXDMStudy.ADX)>25&&vADX.getValue(ADXDMStudy.ADX)<45&&vADX.getValue(ADXDMStudy.PDI)<vADX.getValue(ADXDMStudy.NDI)){
drawTextAbsolute( 0, 15, "ADX: " + vADX14.toFixed(2) +" ", Color.black, Color.magenta,
Text.BOLD | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, "Arial", 10, "ADX" );
}
if(vADX.getValue(ADXDMStudy.ADX)>45&&vADX.getValue(ADXDMStudy.PDI)>vADX.getValue(ADXDMStudy.NDI)){
drawTextAbsolute( 0, 15, "ADX: " + vADX14.toFixed(2) +" ", Color.black, Color.red,
Text.BOLD | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, "Arial", 10, "ADX" );
}
if(vADX.getValue(ADXDMStudy.ADX)>45&&vADX.getValue(ADXDMStudy.PDI)<vADX.getValue(ADXDMStudy.NDI)){
drawTextAbsolute( 0, 15, "ADX: " + vADX14.toFixed(2) +" ", Color.black, Color.lime,
Text.BOLD | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, "Arial", 10, "ADX" );
}
if(vADX.getValue(ADXDMStudy.ADX)<18){
drawTextAbsolute( 0, 15, "ADX: " + vADX14.toFixed(2) +" ", Color.black, Color.yellow,
Text.BOLD | Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM, "Arial", 10, "ADX" );
}
return null;
}
Comment