Need a little help with something I can't seem to find the answer to. Down below you will see the code for a nice little efs that plots a symbol with its moving average as a non price study. The default colors are blue for the indicator and red for its moving average. If click on the "edit studies" you can change the color. EXCEPT, when you change the color both the indicator and its moving average change colors. So. How would one change the efs so that both the indicator and its moving average can have their colors and line widths changed independently from the "edit studies" window?
thanks
efs code follows:
/*********************************
Provided By : eSignal. (c) Copyright 2003
*********************************/
/* plots a symbol and its mov ave as an indicator 6-13-03 **/
var vLoaded = false;
var cSym = "";
var vSym = null;
var vMAArray = new Array();
function preMain() {
if (vLoaded == false) {
setStudyTitle(" ... Add Symbol");
setCursorLabelName("Add Symbol");
setDefaultBarFgColor(Color.blue,0);
setDefaultBarFgColor(Color.red,1);
} else {
if (vSym != null) {
setStudyTitle(" ");
setCursorLabelName(vSym,0);
setCursorLabelName("MA of "+vSym,1);
} else {
setStudyTitle(" ... Add Symbol");
setCursorLabelName("Add Symbol");
}
}
}
function main(Symbol1,nMALength) {
if (vLoaded == false) {
cSym = getSymbol();
if (Symbol1 == null) {
vSym = null;
} else {
vSym = Symbol1;
}
vLoaded = true;
preMain();
}
if (nMALength == null) {
nMALength = 20;
} else {
nMALength = Math.round(nMALength);
}
if (vSym != null) {
var b = close(vSym);
var nBarState = getBarState();
if (nBarState == BARSTATE_NEWBAR) vMAArray.unshift(b); //inserts array element to the front of the array
vMAArray[0] = b;
if (vMAArray[nMALength-1] != null) {
var vSum = 0;
for (i=0; i <= nMALength-1; i++) {
vSum += vMAArray[i];
}
var vMA = vSum / nMALength;
}
return new Array (b,vMA);
} else {
return;
}
}
thanks
efs code follows:
/*********************************
Provided By : eSignal. (c) Copyright 2003
*********************************/
/* plots a symbol and its mov ave as an indicator 6-13-03 **/
var vLoaded = false;
var cSym = "";
var vSym = null;
var vMAArray = new Array();
function preMain() {
if (vLoaded == false) {
setStudyTitle(" ... Add Symbol");
setCursorLabelName("Add Symbol");
setDefaultBarFgColor(Color.blue,0);
setDefaultBarFgColor(Color.red,1);
} else {
if (vSym != null) {
setStudyTitle(" ");
setCursorLabelName(vSym,0);
setCursorLabelName("MA of "+vSym,1);
} else {
setStudyTitle(" ... Add Symbol");
setCursorLabelName("Add Symbol");
}
}
}
function main(Symbol1,nMALength) {
if (vLoaded == false) {
cSym = getSymbol();
if (Symbol1 == null) {
vSym = null;
} else {
vSym = Symbol1;
}
vLoaded = true;
preMain();
}
if (nMALength == null) {
nMALength = 20;
} else {
nMALength = Math.round(nMALength);
}
if (vSym != null) {
var b = close(vSym);
var nBarState = getBarState();
if (nBarState == BARSTATE_NEWBAR) vMAArray.unshift(b); //inserts array element to the front of the array
vMAArray[0] = b;
if (vMAArray[nMALength-1] != null) {
var vSum = 0;
for (i=0; i <= nMALength-1; i++) {
vSum += vMAArray[i];
}
var vMA = vSum / nMALength;
}
return new Array (b,vMA);
} else {
return;
}
}
Comment