Hi-- I'm trying to color the bars above & below the 0 line on a price oscillator. Based on info in the help section, I've been able to add my 0 line, but no matter how I try to to follow the examples in "help" to add 1 color above & 1 color below, the same color appears above & below the line. Can anyone help? Thanks.
Announcement
Collapse
No announcement yet.
Color Bars <> 0 Line
Collapse
X
-
Hi Alexis--WOW! Thanks for your rapid response. I'm trying to modify your own price oscillator from July 2003. I have the following:
var vOsc=null;
function preMain(){
setStudyTitle("Price Oscillator");
setCursorLabelName("Long",0);
setCursorLabelName("Short",1);
setDefaultBarThickness(2,0);
setDefaultBarThickness(2,1);
setPlotType(PLOTTYPE_HISTOGRAM);
functionmain(){
var vOsc;
addBand(0,PS_SOLID,1,Color.black,"zero");
if(vOsc > 0){
setBarFgColor(Color.blue,0);
}
else{
setBarFgColor(Color.red,1);
}
var fp1= new FunctionParameter("Short", Function Parameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(10);
var fp2= new FunctionParameter("Long", FunctionParameter.NUMBER);
fp2.setLowerLimit(1);
fp2.setDefault(21);
var fp3= new FunctionParameter("Source", FunctionParameterSTRING);
fp3.setName("MA1Source");
fp3.addOption("Close");
fp3.addOption("High");
fp3.addOption("Low");
fp3.addOption("Open"):
fp3.addOption("HL/2");
fp3.addeOption("HLC/3");
fp3.addOption("OHLC/4");
fp3.setDefault("Close");
var fp4= new FunctionParameter("Type", FunctionParameter.BOOLEAN);
fp4.setName("Exponential");
fp4.setDefault(false);
}
function main(Short,Lomg,Source,Type({
if (vOsc==null) vOsc=newOscStudy(Short,Long,Source,Type);
return vOsc.getValue(OscStudy.OSC);
}
}
I'm sorry about the grumpy face on my question. I meant it to be a question face. Thanks for your help.
Diane
Comment
-
Diane
In between these two lines
PHP Code:if (vOsc==null) vOsc=newOscStudy(Short,Long,Source,Type);
return vOsc.getValue(OscStudy.OSC);
PHP Code:if(vOsc.getValue(OscStudy.OSC)>=0)
setBarFgColor(Color.green);
if(vOsc.getValue(OscStudy.OSC)<0)
setBarFgColor(Color.red);
PHP Code:functionmain(){
var vOsc;
addBand(0,PS_SOLID,1,Color.black,"zero");
if(vOsc > 0){
setBarFgColor(Color.blue,0);
}
else{
setBarFgColor(Color.red,1);
}
Alex
Comment
-
Hi ,again, Alexis--oops. The zero line does NOT show up. Sorry. Thanks so much for your help. However, now, only the red color appears up & down. I've also encountered another problem. Under Chart Options, under Basic Studies, there is a price oscillator with the options,etc, we're working with in this problem. I can not make any changes to that study. However, under Chart Options, Formulas, under EFS 2 Basic is your BasicOsc.efs. This is the one I am trying to modify, but no edits can be made. Would it be acceptable to input the study again in the EFS editor as a new study? Thanks. Sorry for all the trouble.
DianeLast edited by Diane P; 07-18-2005, 11:07 AM.
Comment
-
Diane
In looking further at the code you posted I found several other syntax errors. I would suggest that you run your code through the syntax checker or start from scratch and use the builtinOsc.efs (which is the original version of the one you posted) that is in the Builtin folder and simply add
if(vOsc.getValue(OscStudy.OSC)>=0)
setBarFgColor(Color.green);
if(vOsc.getValue(OscStudy.OSC)<0)
setBarFgColor(Color.red);
where indicated in that script.
Alex
Comment
Comment