• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

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!
 

Cribbage

New member
I'm interested in this too. I have been tinkering with the ToS Accumulation Distribution indicator as part of a strategy and would like the study's length to be relevant to a stock's beta. Ideally: Length = Beta * 6

I understand why I couldn't use this as is because I assume beta may change throughout the day making it too taxing for ToS. I would be just as happy if the indicator worked from the Beta from the previous day's close.

Does anyone know if there is a work around for this, or is it too much for ToS?
 

Similar threads

Top