It is impossible to see the future! Writing some code to predict it, is definitely not going to work.
This is why your "bot" fails.
We aren't yet in the unpredictable territory either. I'd say at the time being because of the halving and the similar patterns in history we are in a more predictable phase where speculation about the price is easier in comparison to other times when certain events cause unpredictable volatility.