I am trying to convert an old script to V5 and get the error below.
zigzag() =>
_isUp = close >= open
_isDown = close <= open
_direction = _isUp[1] and _isDown ? -1 : _isDown[1] and _isUp ? 1 : nz (_direction[1])
_zigzag = _isUp[1] and _isDown and _direction[1] != -1 ? ta.highest(2) : _isDown[1] and _isUp and _direction[1] != 1 ? ta.lowest(2) : na
Undeclared identifier '_direction'
Variable '_direction' is not found in scope 'zigzag', cannot register side effect
What is the problem here? Do you have any recommendations?