Uptrend Downtrend Loopback Candle Identification Lib
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AugustoErni

//@version=5
library("uptrend_downtrend_loopback_candle_identification_lib", overlay=true)

export uptrendLoopbackCandleIdentification(int lookbackPeriod) =>
    var bool isUptrend = false
    for i = 1 to lookbackPeriod
        if low > low[i]
            isUptrend := true
        else
            isUptrend := false
            break
    isUptrend

export downtrendLoopbackCandleIdentification(int lookbackPeriod) =>
    var bool isDowntrend = false
    for i = 1 to lookbackPeriod
        if low < low[i]
            isDowntrend := true
        else
            isDowntrend := false
            break
    isDowntrend
