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

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.