# Your own functions

name(a, b) = formula; longer ones indent their lines.

```vex
spread(src, n) = highest(src, n) - lowest(src, n)

plot(spread(close, 20), "Spread")
```

A longer function indents its lines; the last line is the result:

```vex
zscore(src, n) =
  m = sma(src, n)
  (src - m) / stdev(src, n)

plot(zscore(close, 20), "Z")
level(2, 0, -2)
```

- Functions can use other functions, but not themselves.
- They take named values like the built-ins: `zscore(n = 50, src = close)`.
- Calling one twice with the same inputs costs nothing extra.
- There are no loops; `loop_score` covers the common for-loop score, and the window functions (`highest`, `sum`, `count`, ...) cover the rest.

See also: [loop_score](/documentation/vex/reference/windows#loop-score)
