FlowScript: Code Your Own Indicators · Lesson 2 of 10 · 7 min

Inputs: settings without code

Let traders tune lengths, colors, sources and switches from the settings dialog.

indicator("Tunable EMA", overlay = true)

length = input("Length", 21, min = 1, max = 500)
src = input("Source", close)
lineColor = input("Color", violet)
showLine = input("Show line", true)

value = ema(src, length)
plot(showLine ? value : na, "EMA", color = lineColor)
DefaultBecomes
A whole number (21)Integer field with optional min/max
A decimal (2.5)Number field; add step = 0.1
true / falseCheckbox
A color (violet, #22c55e)Color picker
A price source (close, hl2)Source dropdown
Text with options = […]Dropdown

Key takeaways

  • input(title, default, …) creates a setting.
  • The default value decides the input type.
  • Inputs go on their own top-level lines.

Next: History and built-in functions