ta.roc()
Rate of Change
Calculates the percentage change of source over the last length bars.
Syntax
ta.roc(source, length) → series floatArguments
| Parameter | Type | Description |
|---|---|---|
| source | series int/float | Series to compute percentage change for. |
| length | series int | Lookback bars for the prior reference value. |
Returns
Rate of change percentage.
Remarks
na values in the source series are included in calculations and will produce an na result.
Code Examples
//@version=6
indicator("ta.roc")
plot(ta.roc(close, 10))
// same on pine
pine_roc(src, length) =>
100 * (src - src[length]) / src[length]
plot(pine_roc(close, 10))Trading Applications
Measure percentage price change over time
Identify momentum extremes for mean reversion
Compare momentum across different securities
Use zero-line crossovers for trend signals
Related Functions
Frequently Asked Questions
Generate ta.roc() Code with AI
Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.roc() and other built-in functions instantly.
Related Pine Script Functions
ta.mom() - Momentum
Learn how to use ta.mom() in Pine Script. Syntax, parameters, code examples for the Momentum indicator.
ta.change() - Change
Learn how to use ta.change() in Pine Script. Calculate bar-to-bar differences for price, time, and boolean series.
ta.rsi() - Relative Strength Index
Learn how to use ta.rsi() in Pine Script. Syntax, parameters, code examples for the RSI momentum oscillator.
ta.cci() - Commodity Channel Index
Learn how to use ta.cci() in Pine Script. Syntax, parameters, code examples for the CCI momentum indicator.
ta.cmo() - Chande Momentum Oscillator
Learn how to use ta.cmo() in Pine Script. Syntax, parameters, code examples for the Chande Momentum Oscillator.