Hi,
I have been trying to plot an ADX line which changes colors when it goes below 10 or above 29. One below it should go red, once above 29 it should go green.
This code here is my last try to make this work. It give me no output. The code before which didn't use the getValue() function gave me one color which never changed.
Any input would be greatly appreciated.
---------------------------------------------------------------------
var fpArray = new Array();
function preMain() {
setPriceStudy(false);
setStudyTitle("ADX");
setCursorLabelName("ADX", 0);
setPlotType(PLOTTYPE_LINE,0);
setDefaultBarThickness(2,0);
var x=0;
fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(14);
}
fpArray[x] = new FunctionParameter("Smoothing", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(14);
}
fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var bInit = false;
var xADX = null;
var xPDI = null;
var xNDI = null;
function main(Length,Smoothing,Symbol,Interval,Params) {
if(bInit == false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
var vSymbol = Symbol+","+Interval;
xADX = adx(Length,Smoothing,sym(vSymbol));
xPDI = pdi(Length,Smoothing,sym(vSymbol));
xNDI = ndi(Length,Smoothing,sym(vSymbol));
setShowTitleParameters(eval(Params));
bInit = true;
}
if (getValue(xADX(0) > 29)) setDefaultBarColor (Color, green);
else if (getValue(xADX(0) <= 10)) setDefaultBarColor (Color, red);
else setDefaultBarColor (Color, yellow);
return new Array (getSeries(xADX));
}
I have been trying to plot an ADX line which changes colors when it goes below 10 or above 29. One below it should go red, once above 29 it should go green.
This code here is my last try to make this work. It give me no output. The code before which didn't use the getValue() function gave me one color which never changed.
Any input would be greatly appreciated.
---------------------------------------------------------------------
var fpArray = new Array();
function preMain() {
setPriceStudy(false);
setStudyTitle("ADX");
setCursorLabelName("ADX", 0);
setPlotType(PLOTTYPE_LINE,0);
setDefaultBarThickness(2,0);
var x=0;
fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(14);
}
fpArray[x] = new FunctionParameter("Smoothing", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(14);
}
fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var bInit = false;
var xADX = null;
var xPDI = null;
var xNDI = null;
function main(Length,Smoothing,Symbol,Interval,Params) {
if(bInit == false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
var vSymbol = Symbol+","+Interval;
xADX = adx(Length,Smoothing,sym(vSymbol));
xPDI = pdi(Length,Smoothing,sym(vSymbol));
xNDI = ndi(Length,Smoothing,sym(vSymbol));
setShowTitleParameters(eval(Params));
bInit = true;
}
if (getValue(xADX(0) > 29)) setDefaultBarColor (Color, green);
else if (getValue(xADX(0) <= 10)) setDefaultBarColor (Color, red);
else setDefaultBarColor (Color, yellow);
return new Array (getSeries(xADX));
}
Comment