Announcement

Collapse
No announcement yet.

Color of Price Bars

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

  • Color of Price Bars

    Hi

    I have green/red candles and I am running a model the autotrades ... when in a long position I would like the bars to be blue and when in a short position I would like the bars to be maroon and then when flat i would like the bars to go back to green/red. Is there a code example anywhere showing how I can do this?

    Many Thanks

    Paul

  • #2
    Paul
    Once you paint the price bars (even if only when long/short) you override the chart's default colors so if you want to see the price bars colored green/red when the strategy is not in a trade you have to set all the conditions that will color the price bars accordingly.
    Enclosed below is an example that assumes that the Up/Down colors are based on the Close being higher/lower than the Open. You will also need to add a setColorPriceBars(true) statement in preMain.
    Alex

    PHP Code:
    if(Strategy.isLong()){
        
    setPriceBarColor(Color.blue);
    }else if(
    Strategy.isShort()){
        
    setPriceBarColor(Color.maroon);
    }else{
        if(
    close(0)>open(0)){
            
    setPriceBarColor(Color.lime);
        }else if(
    close(0)<open(0)){
            
    setPriceBarColor(Color.red);
        }else{
            
    setPriceBarColor(Color.black);
        }

    Comment


    • #3
      Alex

      thanks again

      Paul

      Comment


      • #4
        Paul
        You are most welcome
        Alex

        Comment

        Working...
        X