Dynamic Length Inputs for indicators

invsto

New member
VIP
When using Thinkscript, only constant lengths are allowed - while other platforms such as TradingView allow the use of dynamic length. Is there an alternate way to achieve this?

Example:

def Avg1 = MovingAverage(averageType, value, length) #I would value length to be dynamic.

TradingView Example:

rsiLen = round(SmoothLen) // Get variable RSI length
idealRSI = irsi(src,rsiLen)
 

invsto

New member
VIP
Hi @BenTen

I would need an indicator output as an input to length. In the example above, say:

def length = max(variable1, variable2);

def Avg1 = MovingAverage(averageType, value, length) ; #Note that value of length changes every bar and is not a constant

The error message that I get is "Only constants expected here: _inline_referenced_param_bSRP_9465_length CL constant function parameter 'length' at 28:12".

I want the value of length to vary by bar.
 

invsto

New member
VIP
I think this is an incorrect question, plotting changing lengths for an indicator does not make sense since we cannot compare the current and the previous bar on the same chart (not orange to orange comparison). Thank you for your help!
 

Similar threads

Top