Skip to Main Content

Painting Clouds

The following script paints an SMA-based color cloud which is green whenever a short SMA is above the long one and red otherwise.

const shortMA = sma(close, 20);
const longMA = sma(close, 50);

color_cloud(shortMA, longMA, 'green', 'red');
Painting Clouds

The following script paints support-resistance zone depth over the candles. It uses RSI to approximate the "strength of potential resistance or support".

describe_indicator("RSI pressure zones");

const ATR_FACTOR = 5;
const LENGTH = 14;

const rsiNormalized = rsi(close, LENGTH).map(value => (value - 50) / 100);
const rsiScaledToAtr = for_every(atr(LENGTH), rsiNormalized, (a, r) => a * r * ATR_FACTOR);
const rsiDoubleScaledToAtr = mult(rsiScaledToAtr, 2);

const rsiLine = add(ohlc4, rsiScaledToAtr);
const rsiLineDouble = add(ohlc4, rsiDoubleScaledToAtr);

color_cloud(ohlc4, rsiLine, '#ff0000', '#00ff00', 'Red Area', 'Green Area');
color_cloud(rsiLine, rsiLineDouble, '#550000', 'green', 'Red Area', 'Green Area');
Chart generated by the RSI pressure zones script