Announcement

Collapse
No announcement yet.

change candle stick colors

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

  • change candle stick colors

    I have a candle stick chart that is using the default colors - red and green. When a given condition occurs I want to change the color of the previous bar to yellow.

    I have read through many of the previous posts and tried some of the examples in my code. The best I have been able to do is change the color of the previous bar to yellow, but then all my following bars are white...How can I make the change to the previous bar without disrupting the default values for the following bars ?

    Thanks in advance -
    Jennifer

  • #2
    Hello Jennifer,

    In order to better answer your questions, I need to see your code. Please post your formula or some example code that you’re using.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Okay, here's something real simple....If the open of the current bar is greater than the open of the previous bar change the color of the previous bar to yellow, otherwise the default candlestick colors ( red and green ) stay....Or at least that's what I want it to do...

      function preMain() {
      setPriceStudy(true);
      setStudyTitle("Candlestick Test");
      setColorPriceBars(true);
      }

      function main() {
      if ( getBarState() == BARSTATE_NEWBAR ) {
      if ( open() < open(-1)) {
      debugPrintln ("Okay, do something");
      setBar(Bar.FgColor, -1, Color.yellow)
      }
      }
      }


      Instead what happens is that all the candlesticks change to white...If I remove the formula the candlesticks go back to normal.
      Thanks -
      Jennifer

      Comment


      • #4
        Hello Jennifer,

        The setBar() function cannot change the color of the price bars, only the color of the data series that you're returning to the chart. You need to add setDefaultPriceBarColor(Color.somecolor); to preMain() and then use setPriceBarColor() to set the color of the current bar. You won't be able to change the price bar color of previous bars, only the current bar.

        PHP Code:
        function preMain() {
            
        setPriceStudy(true);
            
        setStudyTitle("Candlestick Test");
            
        setColorPriceBars(true);
            
        setDefaultPriceBarColor(Color.green);
        }

        var 
        vColor Color.green;

        function 
        main() {
            
            if ( 
        getBarState() == BARSTATE_NEWBAR ) {
                
        vColor Color.green;
                if ( 
        open() < open(-1)) {
                    
        //debugPrintln ("Okay, do something");
                    //setBar(Bar.FgColor, -1, Color.yellow)
                    
        vColor Color.yellow;
                }
            }
            
            
        setPriceBarColor(vColor);
            
            return;

        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Thanks, Jason. That answers my question, not the way I would have liked, but it answers my question.

          Comment

          Working...
          X