Announcement

Collapse
No announcement yet.

Change color of bar chart?

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

  • Change color of bar chart?

    I'm using V11.
    I have a simple barchart of the eminiS&P Continuous Future with all bars colored black.
    What I can't manage to do is to write an EFS program to color the bars according to rules of my own.
    For example, I'd like the default color to be black, but, if high(0)>high(-1) and close(0) < (high(0)+low(0))/2 then I'd like the bar color to be red.
    Does anyone know how to do this?

  • #2
    Sorry to trouble you all. Eventually I figured it out. Here's the code.

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("Divergent Bars");
    setComputeOnClose();
    setColorPriceBars(true);
    setDefaultPriceBarColor(Color.black);

    }

    function main() {

    if (stochK(14,3,3) > 75
    && high(0) > high(-1)
    && close(0) < (high(0)+low(0))/2) {
    setPriceBarColor(Color.red)};

    if (stochK(14,3,3) < 25
    && low(0) < low(-1)
    && close(0) > (high(0)+low(0))/2) {
    setPriceBarColor(Color.lime)};

    return;
    }

    Comment

    Working...
    X