Hello, would anyone know how to add to the code so that if the command to buy (if the previous price is below the lower band and the current price >= lower band) goes through, it would then liquidate if the price = middle band?

I made an attempt but it is wrong.