Worked examples

Bollinger Bands with a shaded channel
indicator('Bollinger', overlay=true)
N    = input.int(20, 'Length', minval=2)
MULT = input.float(2.0, 'Deviations', minval=0.1, step=0.1)

MID: MA(CLOSE, N), COLORYELLOW;
UB:  MID + MULT * STD(CLOSE, N), COLORLIBLUE;
LB:  MID - MULT * STD(CLOSE, N), COLORLIBLUE;
FILLRGN(1, UB, LB), COLOR0A2A1A;
Oscillator on a fixed 0–100 axis
indicator('RSI', overlay=false, scale=scale.none, min=0, max=100, ticks=5)
N = input.int(14, 'Length', minval=2)

LC   := REF(CLOSE, 1);
RSI1: SMA(MAX(CLOSE - LC, 0), N, 1) / SMA(ABS(CLOSE - LC), N, 1) * 100, COLORYELLOW, LINETHICK2;
70:   70, COLORGRAY, DOTLINE;
30:   30, COLORGRAY, DOTLINE;
DRAWGBK(RSI1 > 70, RGB(60,20,20), RGB(30,10,10), 90);
Signal markers driven by two indicators
indicator('KDJ + MACD confluence', overlay=true)

J   := KDJ.J;
DIF := MACD.DIF;
DEA := MACD.DEA;

LONG  := CROSS(DIF, DEA) AND J < 30;
SHORT := CROSS(DEA, DIF) AND J > 70;

DRAWICON(LONG,  LOW,  85);
DRAWICON(SHORT, HIGH, 97);
DRAWTEXT(LONG, LOW, 'long'), COLORGREEN, VALIGN2, YMOVE(14);
SIG: IF(LONG, 1, IF(SHORT, -1, 0)), NODRAW, EXDATA;
Colouring candles by a condition
indicator('Trend candles', overlay=true)
N = input.int(20, 'Length', minval=2)

TREND := MA(CLOSE, N);
DRAWCOLORKLINE(CLOSE > TREND, COLORMINT, 0);
DRAWCOLORKLINE(CLOSE <= TREND, COLORCORAL, 0);
STICKLINE(CLOSE > TREND, TREND, TREND, 10, 0), COLORMINTDARK;