I’d like to use the timeframe(n) instruction inside an if block, like the code below but it throws an error:
htf=1
if htf then
timeframe(15mn)
x = ExponentialAverage[9](close)
endif
Is there any workaround ?
Thx
It’s not allowed.
TIMEFRAME must be used outside IF…ENDIF as well as outside iterations and the number and type of units (minute, hours,….) CANNOT be a variable.
OK , there’s an easy workaround:
htf = 1 //flag
timeframe(15mn)
y = ExponentialAverage[9](close)
timeframe(default)
if htf then
x = y
endif
Link to above logged as 254 here …
Snippet Link Library