Newbie here. I have an old program that Alexis wrote, symbol&maHistogram.efs. How do I modify the color of $TVOL bar based on whether the displayed price was up or down. In other words, I'd like to change $TVOL to green bar when displayed symbol price is up and red when down. Thanks.
/********************************
Alexis C. Montenegro ® April 2003
*********************************/
function preMain() {
setPriceStudy(false);
setCursorLabelName("Sym", 0);
setCursorLabelName("SymMA", 1);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarThickness(4, 0);
setDefaultBarThickness(2, 1);
setPlotType(PLOTTYPE_HISTOGRAM, 0);
setPlotType(PLOTTYPE_LINE, 1);
}
function main(nSym,nInputLength) {
if (nSym==null)
nSym = "$TVOL";
if(nInputLength == null)
nInputLength = 10;
var nLength = nInputLength;
var i;
var vSum = 0.0;
var vValue;
vValue = getValue("Close", 0, -nLength,nSym);
if(vValue == null) {
return;
}
for(i = 0; i < nLength; i++) {
vSum += vValue[i];
}
var vMA = (vSum/nLength);
var vSym = getValue("Close",nSym)
return new Array(vSym,vMA);
}
/********************************
Alexis C. Montenegro ® April 2003
*********************************/
function preMain() {
setPriceStudy(false);
setCursorLabelName("Sym", 0);
setCursorLabelName("SymMA", 1);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarThickness(4, 0);
setDefaultBarThickness(2, 1);
setPlotType(PLOTTYPE_HISTOGRAM, 0);
setPlotType(PLOTTYPE_LINE, 1);
}
function main(nSym,nInputLength) {
if (nSym==null)
nSym = "$TVOL";
if(nInputLength == null)
nInputLength = 10;
var nLength = nInputLength;
var i;
var vSum = 0.0;
var vValue;
vValue = getValue("Close", 0, -nLength,nSym);
if(vValue == null) {
return;
}
for(i = 0; i < nLength; i++) {
vSum += vValue[i];
}
var vMA = (vSum/nLength);
var vSym = getValue("Close",nSym)
return new Array(vSym,vMA);
}