```
#addchart - up/down heiken ashi candle colors - workaround for the addchart() function not supported by TOS
def HAclose = (open + high + low + close) / 4;
def HAopen = CompoundValue( 1, ( HAopen[1] + HAclose[1] ) / 2, HAclose );
def HAhigh = Max(Max(high, HAopen), HAclose);
def HAlow = Min(Min(low, HAopen), HAclose);
def o = haopen;
def c = haclose;
def h = hahigh;
def l = halow;
AddChart(if c > o then h else Double.NaN,
if c > o then l else Double.NaN,
if c > o then c else Double.NaN,
if c > o then o else Double.NaN,
ChartType.CANDLE, Color.GREEN);
AddChart(if c < o then h else Double.NaN,
if c < o then l else Double.NaN,
if c < o then o else Double.NaN,
if c < o then c else Double.NaN,
ChartType.CANDLE, Color.RED);
AddChart(if c == o then h else Double.NaN,
if c == o then l else Double.NaN,
if c == o then o else Double.NaN,
if c == o then c else Double.NaN,
ChartType.CANDLE, Color.WHITE);
```