Casey Harrils
Casey Harrils

Reputation: 2963

Dynamic assignment of input variables for Pine script 4.0

I am trying to assign the default ATR Resolution to be the same as the current Chart being used. So,

Pseudocode I am trying to write:

timeframe = '1'
current = timeframe.period
if current != timeframe
    timeframe = current

i_atrRes  = input(defval=timeframe, type=input.resolution, title='ATR Resolution', group="STOP LOSS - used only if 'ATR' selected")

I have been looking at information on this link: https://backtest-rookies.com/2019/03/15/tradingview-daily-atr-stop/

This is what I have encountered so far ...
timeframe = "'" + timeframe.period  + "'"   < --- does not work
timeframe = "'" + tostring(1)  + "'"        < --- does not work
timeframe = '1'                             < --- works

for the statement below:

i_atrRes = input(defval=timeframe, type=input.resolution, title='ATR Resolution', group="STOP LOSS - used only if 'ATR' selected")

How can I do this?

Upvotes: 0

Views: 732

Answers (1)

Kai Gouthro
Kai Gouthro

Reputation: 76

i_atrRes  = input('', type=input.resolution)

Upvotes: 2

Related Questions