Anyone knows how to make a change the histogram color to red when below 0 and blue when above ? Thank you
/Z-score indicator/
var ma=null;
function preMain()
{
setPlotType(PLOTTYPE_HISTOGRAM);
setStudyTitle("Zscore");
setCursorLabelName("Zscore",0);
setDefaultBarFgColor(Color.red,2);
addBand(1,PS_DOT,1,Color.black);
addBand(-1,PS_DOT,1,Color.black);
addBand(2.5,PS_SOLID,2,Color.black);
addBand(-2.5,PS_SOLID,2,Color.black);
addBand(2,PS_SOLID,1,Color.black);
addBand(-2,PS_SOLID,1,Color.black);
}
function main(Period) {
var StdDev = 0;
var SumSqr = 0;
var counter = 0;
if(Period == null)
Period = 20;
if(ma == null)
ma = new MAStudy(Period, 0, "HLC/3", MAStudy.Simple);
for(counter = - Period + 1; counter <=0; counter++)
SumSqr +=Math.pow((close(counter) - ma.getValue(MAStudy.MA)),2);
StdDev = Math.sqrt(SumSqr / Period);
return (close() - ma.getValue(MAStudy.MA)) / StdDev;
}
/Z-score indicator/
var ma=null;
function preMain()
{
setPlotType(PLOTTYPE_HISTOGRAM);
setStudyTitle("Zscore");
setCursorLabelName("Zscore",0);
setDefaultBarFgColor(Color.red,2);
addBand(1,PS_DOT,1,Color.black);
addBand(-1,PS_DOT,1,Color.black);
addBand(2.5,PS_SOLID,2,Color.black);
addBand(-2.5,PS_SOLID,2,Color.black);
addBand(2,PS_SOLID,1,Color.black);
addBand(-2,PS_SOLID,1,Color.black);
}
function main(Period) {
var StdDev = 0;
var SumSqr = 0;
var counter = 0;
if(Period == null)
Period = 20;
if(ma == null)
ma = new MAStudy(Period, 0, "HLC/3", MAStudy.Simple);
for(counter = - Period + 1; counter <=0; counter++)
SumSqr +=Math.pow((close(counter) - ma.getValue(MAStudy.MA)),2);
StdDev = Math.sqrt(SumSqr / Period);
return (close() - ma.getValue(MAStudy.MA)) / StdDev;
}
Comment