I am getting the following error trying to declare a variable in my pinescript.
Cannot call 'input' with 'defval'=series[integer]
Script code:
// Function to determine the input value based on the timeframe
f_get_period_input() =>
var int period = na
if (timeframe.isintraday and timeframe.multiplier == 60) // Hourly timeframe
period := 24
else if (timeframe.isdaily) // Daily timeframe
period := 30
else
period := na
// Get the appropriate period value
period_input = f_get_period_input()
// Use the period_input in your script
periods = input(period_input != na ? period_input : 3, minval=1, title="Moving Average Period")