Hello,
I would like the following price hist to be green when moving up and red when moving down.
Currently i get color change when it goes above and below the zero line.
Can anyone help with the added script lines?
Thanks,
var vOsc = null;
function preMain() {
setStudyTitle("Price Oscillator");
setCursorLabelName("Osc");
setDefaultBarFgColor(Color.blue);
setDefaultBarThickness(4);
setPlotType(PLOTTYPE_HISTOGRAM);
addBand(0, PS_SOLID, 1, Color.lightgrey);
checkVersion(1,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/basicOsc.efs");
var fp1 = new FunctionParameter("Short", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(8);
var fp2 = new FunctionParameter("Long", FunctionParameter.NUMBER);
fp2.setLowerLimit(1);
fp2.setDefault(20);
var fp3 = new FunctionParameter("Source", FunctionParameter.STRING);
fp3.setName("MA1Source");
fp3.addOption("Close");
fp3.addOption("High");
fp3.addOption("Low");
fp3.addOption("Open");
fp3.addOption("HL/2");
fp3.addOption("HLC/3");
fp3.addOption("OHLC/4");
fp3.setDefault("Close");
var fp4 = new FunctionParameter("Type", FunctionParameter.BOOLEAN);
fp4.setName("Exponential");
fp4.setDefault(true); //Edit this value to set a new default
}
function main(Short, Long, Source, Type) {
if (vOsc == null) vOsc = new OscStudy(Short, Long, Source, Type);
/********************************************
Insert your code following this text block
Use vOsc.getValue(OscStudy.OSC) for your code
*********************************************/
if (vOsc.getValue(OscStudy.OSC)>0)
setBarFgColor(Color.green);
if(vOsc.getValue(OscStudy.OSC)<0)
setBarFgColor(Color.red);
return vOsc.getValue(OscStudy.OSC);
}
I would like the following price hist to be green when moving up and red when moving down.
Currently i get color change when it goes above and below the zero line.
Can anyone help with the added script lines?
Thanks,
var vOsc = null;
function preMain() {
setStudyTitle("Price Oscillator");
setCursorLabelName("Osc");
setDefaultBarFgColor(Color.blue);
setDefaultBarThickness(4);
setPlotType(PLOTTYPE_HISTOGRAM);
addBand(0, PS_SOLID, 1, Color.lightgrey);
checkVersion(1,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/basicOsc.efs");
var fp1 = new FunctionParameter("Short", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(8);
var fp2 = new FunctionParameter("Long", FunctionParameter.NUMBER);
fp2.setLowerLimit(1);
fp2.setDefault(20);
var fp3 = new FunctionParameter("Source", FunctionParameter.STRING);
fp3.setName("MA1Source");
fp3.addOption("Close");
fp3.addOption("High");
fp3.addOption("Low");
fp3.addOption("Open");
fp3.addOption("HL/2");
fp3.addOption("HLC/3");
fp3.addOption("OHLC/4");
fp3.setDefault("Close");
var fp4 = new FunctionParameter("Type", FunctionParameter.BOOLEAN);
fp4.setName("Exponential");
fp4.setDefault(true); //Edit this value to set a new default
}
function main(Short, Long, Source, Type) {
if (vOsc == null) vOsc = new OscStudy(Short, Long, Source, Type);
/********************************************
Insert your code following this text block
Use vOsc.getValue(OscStudy.OSC) for your code
*********************************************/
if (vOsc.getValue(OscStudy.OSC)>0)
setBarFgColor(Color.green);
if(vOsc.getValue(OscStudy.OSC)<0)
setBarFgColor(Color.red);
return vOsc.getValue(OscStudy.OSC);
}
Comment