I tried a few ways but they did not work and could use a small favor.
When the MA is greater then 250 the background truns one colr and when less then 250 the background turns another. I have gotten real rusty. If someone could add the 2 lines of code I would greatly appreciateit. Kind of frustrated with my results.
Thanks
Earl
[email protected]
/************************************************** *******
Alexis C. Montenegro © December 2004
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 fpArray = new Array();
function preMain() {
setPriceStudy(false);
setStudyTitle("VolumeMA");
setCursorLabelName("Vol", 0);
setCursorLabelName("maVol", 1);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarFgColor(Color.black, 0);
setDefaultBarFgColor(Color.black, 1);
setDefaultBarThickness(2, 0);
setDefaultBarThickness(2, 1);
setPlotType(PLOTTYPE_HISTOGRAM, 0);
setPlotType(PLOTTYPE_LINE, 1);
askForInput();
setStudyMin(1);
setStudyMax(500);
var x = 0;
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("MAType", FunctionParameter.STRING);
with(fpArray[x++]){
addOption("sma");
addOption("ema");
addOption("wma");
setDefault("sma");
}
fpArray[x] = new FunctionParameter("MALength", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(20);
}
fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Color based on");
addOption("Price");
addOption("Volume");
setDefault("Price");
}
fpArray[x] = new FunctionParameter("ColorUp", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("Up Color");
setDefault(Color.blue);
}
fpArray[x] = new FunctionParameter("ColorDn", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("Down Color");
setDefault(Color.red);
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var bInit = false;
var vSymbol = null;
var xMAofVol = null;
function main(Symbol,Interval,MAType,MALength,Source,ColorU p,ColorDn,Params) {
if(bInit == false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
vSymbol = Symbol+","+Interval;
xMAofVol = eval(MAType)(MALength,volume(sym(vSymbol)));
setShowTitleParameters(eval(Params));
bInit = true;
}
if(Source=="Price"){
if (close(sym(vSymbol)) < open(sym(vSymbol)))
setBarFgColor(ColorDn,0);
else if (close(sym(vSymbol)) > open(sym(vSymbol)))
setBarFgColor(ColorUp,0);
else if (close(sym(vSymbol)) == open(sym(vSymbol)))
setBarFgColor(Color.black,0);
}
if(Source=="Volume"){
if (volume(sym(vSymbol)) < volume(-1,sym(vSymbol)))
setBarFgColor(ColorDn,0);
else if (volume(sym(vSymbol)) > volume(-1,sym(vSymbol)))
setBarFgColor(ColorUp,0);
else if (volume(sym(vSymbol)) == volume(-1,sym(vSymbol)))
setBarFgColor(Color.black,0);
}
return new Array (volume(sym(vSymbol)),getSeries(xMAofVol));
}
When the MA is greater then 250 the background truns one colr and when less then 250 the background turns another. I have gotten real rusty. If someone could add the 2 lines of code I would greatly appreciateit. Kind of frustrated with my results.
Thanks
Earl
[email protected]
/************************************************** *******
Alexis C. Montenegro © December 2004
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 fpArray = new Array();
function preMain() {
setPriceStudy(false);
setStudyTitle("VolumeMA");
setCursorLabelName("Vol", 0);
setCursorLabelName("maVol", 1);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarFgColor(Color.black, 0);
setDefaultBarFgColor(Color.black, 1);
setDefaultBarThickness(2, 0);
setDefaultBarThickness(2, 1);
setPlotType(PLOTTYPE_HISTOGRAM, 0);
setPlotType(PLOTTYPE_LINE, 1);
askForInput();
setStudyMin(1);
setStudyMax(500);
var x = 0;
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("MAType", FunctionParameter.STRING);
with(fpArray[x++]){
addOption("sma");
addOption("ema");
addOption("wma");
setDefault("sma");
}
fpArray[x] = new FunctionParameter("MALength", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(20);
}
fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Color based on");
addOption("Price");
addOption("Volume");
setDefault("Price");
}
fpArray[x] = new FunctionParameter("ColorUp", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("Up Color");
setDefault(Color.blue);
}
fpArray[x] = new FunctionParameter("ColorDn", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("Down Color");
setDefault(Color.red);
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var bInit = false;
var vSymbol = null;
var xMAofVol = null;
function main(Symbol,Interval,MAType,MALength,Source,ColorU p,ColorDn,Params) {
if(bInit == false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
vSymbol = Symbol+","+Interval;
xMAofVol = eval(MAType)(MALength,volume(sym(vSymbol)));
setShowTitleParameters(eval(Params));
bInit = true;
}
if(Source=="Price"){
if (close(sym(vSymbol)) < open(sym(vSymbol)))
setBarFgColor(ColorDn,0);
else if (close(sym(vSymbol)) > open(sym(vSymbol)))
setBarFgColor(ColorUp,0);
else if (close(sym(vSymbol)) == open(sym(vSymbol)))
setBarFgColor(Color.black,0);
}
if(Source=="Volume"){
if (volume(sym(vSymbol)) < volume(-1,sym(vSymbol)))
setBarFgColor(ColorDn,0);
else if (volume(sym(vSymbol)) > volume(-1,sym(vSymbol)))
setBarFgColor(ColorUp,0);
else if (volume(sym(vSymbol)) == volume(-1,sym(vSymbol)))
setBarFgColor(Color.black,0);
}
return new Array (volume(sym(vSymbol)),getSeries(xMAofVol));
}
Comment