Hello,
My histogram plots ok (under an intraday chart), but the bars colors won't do what I want. Increasing 'green' bars should be lime .. decreasing ones olive.
And decreasing 'red' bars should be red .. increasing ones pink. Sometimes the color change occurs, but often it doesn't. Any idea what I have done wrong?
And on intraday One-Day-Only plots, the first bar is very skinny (and often the wrong color) .. can that be fixed?
Thanks in advance
shaeffer
My histogram plots ok (under an intraday chart), but the bars colors won't do what I want. Increasing 'green' bars should be lime .. decreasing ones olive.
And decreasing 'red' bars should be red .. increasing ones pink. Sometimes the color change occurs, but often it doesn't. Any idea what I have done wrong?
And on intraday One-Day-Only plots, the first bar is very skinny (and often the wrong color) .. can that be fixed?
Thanks in advance
shaeffer
PHP Code:
function preMain(){
setPriceStudy(false);
setStudyTitle("Nas Pct Dn Vol-3");
setShowCursorLabel(false);
setShowTitleParameters( false );
setDefaultBarFgColor(Color.yellow ,0);
setPlotType(PLOTTYPE_HISTOGRAM, 0);
setHistogramBase( 50 );
//setPlotType( PLOTTYPE_LINE,0);
setDefaultBarThickness(4,0);
addBand( 80.0, PS_DASH, 1, Color.white, 0);
addBand( 20.0, PS_DASH, 1, Color.white, 1);
}
var xUpVol = null;
var xDnVol = null;
var vUpVol1;
var vDnVol1;
var bInit = false;
function main(){
var vUpVol = null;
var vDnVol = null;
var vol;
if(bInit == false){
xUpVol = close(sym("$UVOLQ"));
xDnVol = close(sym("$DVOLQ"));
bInit = true;
}
vUpVol = xUpVol.getValue(0);
vDnVol = xDnVol.getValue(0);
Tvol = vUpVol + vDnVol;
vol = vUpVol /Tvol * 100;
if (getBarState() == BARSTATE_NEWBAR) {
vUpVol1 = xUpVol.getValue(-1);
vDnVol1 = xDnVol.getValue(-1);
//Calculates previous bar values only once, when new bar starts (vs every tick)
}
if(vUpVol >= vDnVol){
if(vUpVol >= vUpVol1){
setBarFgColor(Color.lime);
}else{
setBarFgColor(Color.olive);
}
}else{
if(vDnVol <= vDnVol1){
setBarFgColor(Color.RGB(250,86,86)); // pink
}else{
setBarFgColor(Color.red);
}
}
drawTextRelative(0,0, "Up Vol = "+ (vol).toFixed(1)+" % ", Color.lime, Color.black,Text.BOLD
|Text.RELATIVETOTOP|Text.RELATIVETOLEFT, null, 11, 200);
drawTextRelative(0,15, "Dn Vol = "+ (100-vol).toFixed(1)+" % ", Color.red, Color.black,Text.BOLD
|Text.RELATIVETOTOP|Text.RELATIVETOLEFT, null, 11, 201);
return (vol);
}
Comment