Petrus
Petrus

Reputation: 321

PineScript TradingView: Going beyond a year in code (12months +)

I'm struggling to write an indicator that uses more than 12 months to calculate... Any help appreciated please!

This works up to 12M:

year = security(tickerid, '12M', open)

But when I go beyond 12 months for example 24 months:

multiyear = security(tickerid, '24M', open)

I get errors:

"Invalid value of the resolution argument"

Upvotes: 1

Views: 745

Answers (1)

vitruvius
vitruvius

Reputation: 21121

Read the documentation (Ctrl+Click (PC) or Cmd+click (MAC) on function).

The resolution argument allowable values are:

  • 1S, 5S, 15S, 30S - for seconds intervals (chart resolution should be less than or equal to the requested resolution)
  • from 1 to 1440 for minutes
  • from 1D to 365D for days
  • from 1W to 52W for weeks
  • from 1M to 12M for months

Going beyond 12+ months seems to be not possible.

Upvotes: 1

Related Questions