TradeZoro
Notifications

Mentis course

Lesson 4. Moving averages and indicators

35 min, foundation level

Most indicators are one function call. The ta namespace holds them: ta.sma, ta.ema, ta.rsi, ta.atr, ta.macd and many more.

//@zscript 1
indicator("Two averages", overlay=true)
fast = ta.ema(close, 9)
slow = ta.ema(close, 21)
plot(fast, color=color.green)
plot(slow, color=color.red)

Some functions give back several values. Take them apart with square brackets: [mid, up, lo] = ta.bb(close, 20, 2.0).

Call ta functions on every bar, not inside an if. They keep a running memory, and skipping bars gives wrong answers.

Exercises

  1. Add RSI. Build an indicator in its own pane: RSI(14) with hline(30) and hline(70).
  2. Bands. Plot Bollinger Bands with ta.bb and shade between the outer lines using fill().

Quick quiz

Which is a fast, reactive average?

EMA weights recent bars more.

Where should ta functions be called?

They keep a running history that needs every bar.

Next lesson

Education only. Not financial advice. Examples are teaching samples, not trading results.

Zscript is coming soon

The manual opens when Zscript launches.

Back to home