Announcement

Collapse
No announcement yet.

setColorPriceBars/setPriceBarColor

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • setColorPriceBars/setPriceBarColor

    ES 7.91 build 738

    function preMain() {
    setPriceStudy(true);
    setStudyTitle("barcolor");

    // setColorPriceBars does not maintain study color properties.
    // depending on color settings (wick/outline/bg/etc) price bars may
    // even "disappear" into the background. The mere existence of the
    // function, when true, causes this behavior. When false, usage
    // of setPriceBarColor triggers the behavior.
    // This is clearly a bug... existing study color properties must be honored
    // unless they are overriden by new default colors via EFS, etc.
    setColorPriceBars(true);
    }

    function main() {

    // just a simple condition for testing.
    if (high(0) > high(-1))
    {
    // if setColorPriceBars(false) one would think this would have no affect. Not the case.
    // And to add insult, study color properties are not honored!
    // if setColorPriceBars(true) study color properties are not honored either.

    // rem/unrem for testing
    // setPriceBarColor(Color.magenta);
    }

    return null;

    }

    For testing you may need to "remove" instead of "reload". Reload produced inconsistent results for me (which suggests a different problem)

  • #2
    Hi drucker,

    This is actually intended behavior of setPriceBarColor(). If you don't specify it on a per bar basis, it will revert to the default bar color (see setDefaultPriceBarColor).

    Other scripting languages, such as EasyScript and WealthScript are procedural in nature. EFS works on a callback basis instead, so the price bar color has to be set for each and every return path.

    ie, this is most evident in WealthScript, where you would set your series plot values, and return the whole thing. In EFS, one returns an individual value per bar in the main() callback method.

    Also, when using setPriceBarColor, you have to use setDefaultPriceBarColor (see docs for the setPriceBarColor method, as this is discussed there).

    It's a bit different conceptually than procedural based languages, but allows us to perform optimizations in the engine that aren't possible with a procedural style language.

    Comment

    Working...
    X