Skip to Main Content

Coloring Lines

The following script paints an SMA which is green if it's below the price action and red if it's above.

describe_indicator('Colored MA');

const ma = sma(close, 20);
const colors = for_every(close, ma, (c, m) => c > m ? 'green' : 'red');

paint(ma, 'MA', colors);
Coloring Lines