On lines 47 and 48, you get the 120min candles of BTC USD, so you already know the closing price of the candle (in the future).
If the open price of the candle is lower than the closing price and that is not the case for the previous one, you open a long trade.
But you already know this trade is happening on a green 120min candle.
You don't start at the beginning of the candle (you start after 1/4), so you might lose, and that is why it can be confusing to lose a trade even if you know the future.
Please guys, take care about predicting future prices when you see unrealistic results.
To be clear to anyone else that reads this description:
** This Indicator doesn’t work as it shows on your screen **
I would suggest putting this on your chart with your other favourite indicators and you might notice correlation or confluence with another indicator when this makes a good call....