Does not existPine Script v6

"source" is not a valid type keyword

source was a v4 input type. In v5 and v6 you use input.source() or the series float type.

Quick answer

In Pine Script v4 you declared a price-source input with input(close, type = input.source). In v5 and v6 that form was removed, and the correct call is input.source(close, "Source"). If you hit this error on a function parameter rather than an input, the fix is different: source is not a type qualifier, so use series float, which is what a price series actually is. Both are straight v4-to-v5 migration issues and neither has a v6-specific twist.

The exact error

"source" is not a valid type keyword.

v5 → v6

source was valid as an input type in v4 only. Pine v5 replaced the whole input(..., type = ...) family with dedicated constructors — input.source(), input.int(), input.float(), input.bool(), input.string(), input.color(), input.time(), input.timeframe(), input.symbol(), input.session() and input.price(). v6 kept the v5 form unchanged.

Why this happens

Pine v5 split the single overloaded input() function into one constructor per type. The old type = input.source argument has no equivalent because the type is now carried by the function name itself.

input.source(close, "Source") returns a series float that the user can point at open, high, low, close, hl2, hlc3, ohlc4 or another indicator on the chart.

The second place this error appears is a user-defined function parameter. Pine has no source type qualifier — a price series is series float, so type the parameter as series float, or leave it untyped and let Pine infer it.

Do not try to fix this by writing input(close, type = source). source is not a keyword you can use anywhere; it only ever existed as part of the v4 input.source enum value.

If you are migrating a longer v4 script, this error rarely appears alone — expect the other v4 input forms and the study() to indicator() rename in the same pass.

What actually works

//@version=6
source-is-not-a-valid-type-keyword.pine
//@version=6
indicator("Source input, v5/v6 style", overlay = true)

// WRONG - v4 syntax, rejected by v5 and v6:
// src = input(close, type = input.source)

// RIGHT - v5/v6 uses a dedicated constructor.
src = input.source(close, "Source")

// A user-defined function taking a price series: the type is "series float",
// there is no "source" type qualifier in the language.
smoothed(series float s, simple int len) =>
    ta.ema(s, len)

length = input.int(20, "Length", minval = 1)
plot(smoothed(src, length), "Smoothed source", color = color.orange)

Copy and paste into the TradingView Pine Editor, or let TradePilot adapt it to your exact case.

FAQ

"source" is not a valid type keyword — common questions

How do I fix "source is not a valid type keyword" in Pine Script?

Replace the v4 form input(close, type = input.source) with the v5/v6 constructor input.source(close, "Source"). If the error is on a function parameter instead, use series float — Pine has no source type qualifier.

What replaced input(..., type = input.source) in Pine v5?

input.source(). Pine v5 split the overloaded input() into one constructor per type, so the type argument disappeared entirely. v6 kept the same form.

What type is a price source in Pine Script?

series float. That covers close, open, high, low, hl2, hlc3, ohlc4 and any plot the user selects from another indicator on the chart.

More Pine reference

Other functions and errors

Never hit this error again.

TradePilot writes Pine Script v6 that's verified to compile before it reaches you — and if your existing script has this error, Pine Studio fixes it, root cause and all, in one pass. Start with 7 days free on any plan; cancel any time before it ends.

7-day free trial · Cancel anytime · No charge until day 7