Writing an indicator
Calculate, draw, and publish values.
indicator "Trend Ribbon"pane: priceinput fast = 20input slow = 50fast_line = ema(close, fast)slow_line = ema(close, slow)export up = fast_line > slow_lineexport strength = (fast_line - slow_line) / atr(14)plot fast_line as fast, color: if up then green else redplot slow_line as slow, color: graypane: pricedraws over the price chart.pane: newgives the indicator its own pane.plotdraws a series.asgives the plot a name. Colours can depend on a condition.exportpublishes a value. Anything exported can be read by a strategy, an alert or another indicator that uses this one.
Using an indicator or a library from another script
use indicator "Trend Ribbon" v3 as ribbon (fast: 10, slow: 30)use library "Quant Toolkit" v2 as qtYou import by name and version, give it a short name with as, and set its inputs in brackets. After that, ribbon.up reads like any other value. A script names the version it uses, so an update to the indicator does not silently change a strategy that depends on it.