Pine script Cannot call 'security' with arguments

1.1k views Asked by At
yr = tostring(year,"NSE:X####")

vol3_ticker = ticker+yr

vol3 = security(vol3_ticker, timeframe.period, volume, lookahead=barmerge.lookahead_on)

Error:

Cannot call 'security' with arguments (series[string], string, series[float], lookahead=const bool); available overloads: security(string, string, series[float], const bool, const bool, string) => series[float]; security(string, string, series[integer], const bool, const bool, string) => series[integer]; security(string, string, series[bool], const bool, const bool, string) => series[bool]; security(string, string, series[color], const bool, const bool, string) => series[color]; security(string, string, , const bool, const bool, string) =>

1

There are 1 answers

0
e2e4 On

Security's symbol argument accept a constant string.

yr = tostring(year,"NSE:X####")

in that case the yr variable will return NSE:X2020 string

Than you are trying to add a current ticker's string from the pine version 3. In the security argument you define the pine version 4 built-in variable as an argument (timeframe.period) - You can't mix the built-in variables from different versions and have to chose on which version of pine you are going to write a script. Define it at the beginning of the script - //@version=4

Current ticker's string in version 4 is syminfo.ticker (was just ticker in version 3)

When you will build a string with vol3_ticker = syminfo.ticker+yr make sure it is in existence in the tradingview's datafeed before forwarding it to the security function.