Announcement

Collapse
No announcement yet.

Histogram bar colors

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Histogram bar colors

    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
    PHP Code:
    function preMain(){
    setPriceStudy(false); 
    setStudyTitle("Nas Pct Dn Vol-3"); 
    setShowCursorLabel(false);
    setShowTitleParametersfalse ); 
    setDefaultBarFgColor(Color.yellow ,0);
    setPlotType(PLOTTYPE_HISTOGRAM0);
    setHistogramBase50 );
    //setPlotType( PLOTTYPE_LINE,0);
    setDefaultBarThickness(4,0);

    addBand(  80.0PS_DASH,  1Color.white,  0);
    addBand(  20.0PS_DASH,  1Color.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.limeColor.black,Text.BOLD
    |Text.RELATIVETOTOP|Text.RELATIVETOLEFTnull11200); 

    drawTextRelative(0,15"Dn Vol = "+ (100-vol).toFixed(1)+" % "Color.redColor.black,Text.BOLD
    |Text.RELATIVETOTOP|Text.RELATIVETOLEFTnull11201);

    return (
    vol);


  • #2
    I got the first problem solved.
    Any help with making the first histo bar display in full width (on an intraday one-day-only chart) would be appreciated.

    Shaeffer

    Comment

    Working...
    X