Announcement

Collapse
No announcement yet.

Price Bar Color

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

  • Price Bar Color

    I'm trying to build a simple price bar color efs, which uses "close" or "hlc3".

    It's the inserting eval for hlc3 that I'm struggling with. The close efs is below. This works. Any ideas how to make it use hlc3 instead?

    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Color Price Bars");
        
    setShowTitleParameters(false);
        
        
    setColorPriceBars(true);
        
    setDefaultPriceBarColor(Color.grey);
    }

    function 
    main() {
        
        if (
    close(0) > close(-1)) {
            
    setPriceBarColor(Color.green);
        }
        
        if (
    close(0) < close(-1)) {
            
    setPriceBarColor(Color.red);
        }
        
        if (
    close(0) == close(-1)) {
            
    setPriceBarColor(Color.grey);
        }
        
        return;


  • #2
    Re: Price Bar Color

    James 88
    For examples on how to create a selector for the different types of sources see the formulas included in the EFS2 Cusrtom folder as most have that option
    That said keep in mind that at this time hlc3() [as well as hl2() and ohlc4()] does not allow to access directly the values of the series using a bar index so you cannot just replace close(-1) with hlc3(-1). You need to first assign the hlc3() series object to a variable and then use the .getValue() method of the series object to retrieve the value from the series. See the article on the Series Object in the EFS KnowledgeBase for an example on using the .getValue() method
    Alex


    Originally posted by James 88
    I'm trying to build a simple price bar color efs, which uses "close" or "hlc3".

    It's the inserting eval for hlc3 that I'm struggling with. The close efs is below. This works. Any ideas how to make it use hlc3 instead?

    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("Color Price Bars");
        
    setShowTitleParameters(false);
        
        
    setColorPriceBars(true);
        
    setDefaultPriceBarColor(Color.grey);
    }

    function 
    main() {
        
        if (
    close(0) > close(-1)) {
            
    setPriceBarColor(Color.green);
        }
        
        if (
    close(0) < close(-1)) {
            
    setPriceBarColor(Color.red);
        }
        
        if (
    close(0) == close(-1)) {
            
    setPriceBarColor(Color.grey);
        }
        
        return;

    Comment

    Working...
    X