How do we initialize default value to an already assigned variable?
For example, I want to first assign some value to variable and then use that conditionally into another variable.
In Pine script, we do that like this below:
So how would above code look like in ToS?
I tried below but that does not give correct answer:
Here, I'm first assigning ohlc4 - atr(12) calculated value and then need to use it to the same variable lowerBand but because in ToS, I've used 2 different variables, its probably messing up result.
Any help is much appreciated!
For example, I want to first assign some value to variable and then use that conditionally into another variable.
In Pine script, we do that like this below:
Code:
lowerBand = ohlc4 - ta.atr(12)
lowerBand := lowerBand > close ? lowerBand : high
So how would above code look like in ToS?
I tried below but that does not give correct answer:
Code:
def lBand = ohlc4 - atr(12);
def lowerBand = if lBand> close then lBand else high;
Here, I'm first assigning ohlc4 - atr(12) calculated value and then need to use it to the same variable lowerBand but because in ToS, I've used 2 different variables, its probably messing up result.
Any help is much appreciated!