SetBarColor Place, Color

SetBarColor is used to show on the graph bars in different colors, depending of the conditions.
  Color codes are:
   clDarkBlue
   clYellow
   clGray
   clBlack
   clLightGreen
   clDarkGreen
   clLightRed
   clDarkRed
   clBrown
   clLightBlue
   clWhite

To use other colors than preselected ones described here, use RGB function

 

This procedure has two parameters:
Place   Enter the place where the selected color will be used on the graph.
Color   Enter here the constant of the color you want to highlight the selected place. Constants are listed above.

 

Example:

' Test Color system
' To see a result, apply it on a graph!
' You can run it but it will return nothing cause there are no buy/sell signals
Sub Main()
  For CurrentBar = BeginBar to EndBar
    If GetValue("SAR", CurrentBar) < Close(CurrentBar) then SetBarColor CurrentBar, clDarkGreen
    If GetValue("SAR", CurrentBar) > Close(CurrentBar) then SetBarColor CurrentBar, clLightRed
    If GetValue("RSI", CurrentBar) < 20 then SetBarColor CurrentBar, clYellow
  Next
End Sub