Announcement

Collapse
No announcement yet.

Painting bars

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

  • Painting bars

    I am using a bar chart and wish to colour the bars to MY specification as follows:
    I wish to colour a bar green if the close of the bar is above the open of the bar AND the the close is ABOVE the mid point of the bar.
    Also I wish to colour a bar red if the close of the bar is below the open of the bar AND the close is BELOW the mid point of the bar.
    Any bar which does not fall within these parameters must be coloured in any colour other than red or green.

    I hope this is clear.
    Thanks for your help.
    David Hudson

  • #2
    David
    The enclosed script will do what you asked.
    Alex

    PHP Code:
    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Paintbar"); 
    setShowCursorLabel(false);
    setColorPriceBars(true);
    setDefaultPriceBarColor(Color.black);
    }

    function 
    main() {

    if(
    close()>open()&&close()>(high()+low())/2){
    setPriceBarColor(Color.lime);
    }
    if(
    close()<open()&&close()<(high()+low())/2){
    setPriceBarColor(Color.red);
    }

    return;

    Comment

    Working...
    X