Converting Pine Script to V5 but it has different output

Viewed 18

Does anyone know why when converting the below to V5 it is compiling upside down?

original:

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
[2]: https://i.stack.imgur.com/HbmX3.png

V5

zigzag() =>
    _isUp = close >= open
    _isDown = close <= open
    _direction = 0
    _direction := _isUp[1] and _isDown ? -1 : _isDown[1] and _isUp ? 1 : nz (_direction[1]) 
    _zigzag = _isUp[1] and _isDown and _direction[1] != -1 ? highest(2) : _isDown[1] and _isUp and _direction[1] != 1 ? lowest(2) : na
[1]: https://i.stack.imgur.com/zm3iF.png Would you know how to fix it, please?

0 Answers
Related