StatisticalPine Script v6

ta.mode()Mode

Returns the mode (most frequent value) of a series over a given number of bars.

Syntax

Syntax
ta.mode(source, length) → series float

Arguments

ParameterTypeDescription
sourceseries int/floatSeries of values to process.
lengthseries intNumber of bars in the rolling window.

Returns

Mode of source for length bars back.

Remarks

na values in the source series are ignored.

Code Examples

Pine Script v6 Example
//@version=6
indicator("ta.mode", overlay=true)
plot(ta.mode(close, 30))

Trading Applications

Find the most frequent price level (potential support/resistance)

Identify price clustering zones

Build volume profile-like analysis

Detect consolidation price levels

Related Functions

Frequently Asked Questions

ta.mode() estimates the most frequently occurring value in the rolling window (after na removal), highlighting where price has clustered.

Repeated prints near the same level can act as magnets or barriers; mode highlights those clusters for mean-reversion or breakout context.

Implementation details follow Pine reference: ties may be resolved by a defined rule. Check TradingView docs for the exact tie-break behavior in your Pine version.

Generate ta.mode() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.mode() and other built-in functions instantly.