Customize a built-in indicator
addScript("EMA") is great for defaults. When you need your periods, colors, or wiring — still no custom math required. You copy the built-in recipe, edit fields, and pass it back in.
What you are building
For example: MACD with faster settings (8 / 21 / 5) instead of the library defaults.
Clone, edit, add
const macd = structuredClone(chart.getScripts().MACD);
macd.inputs.FPERIOD.value = 8;
macd.inputs.SPERIOD.value = 21;
macd.inputs.SGPERIOD.value = 5;
chart.addScript("MACD", macd);
Always clone with structuredClone (or JSON.parse(JSON.stringify(...))). Objects from getScripts() are shared templates — editing them directly causes weird bugs.
See advanced wiring live
Some indicators read another indicator's output (for example “trade when EMA crosses SMA”). The showcase below demonstrates those patterns:
Two moving-average outputs are rewired into CROSS so the strategy follows EMA/SMA intersections instead of the default MACD pair.
Full explanations: Programmatic wiring.
Update an indicator already on the chart
chart.updateIndicator(scriptId, updatedDefinition);
Use this when the user changes a setting in your settings panel.
When built-ins are not enough
If you need a completely new formula that does not exist in the catalog, that is a maintainer task: Custom indicator authoring.
What is next?
- Add an indicator — first steps with EMA and RSI
- Quant analytics demo — heavy indicator dashboards