Products generally follow a trend of Lower price -> higher sales Higher price -> lower sales

Is there a way to optimise the price for maximising revenue/profit? For example, if my product is $8 and I make 100 sales a month, I’d make $800 a month in revenue. An increase to $12 might drop me to 80 sales a month, making $960, but I’m still making an extra $120 However, an increase to $15 might drop me to 50 sales, which leaves me at $750 a month, which is -$50 Inversely, I might drop price to $5 a month which lets say brings in 170 sales, where I’d be making $850, which is an extra $50

So my question is, is there a way to predict and optimise the returns when increasing/decreasing price? Is there a metric that can forecast the rise/drop in customers? Do you just need to do A/B testing? I’ve struggled with my pricing in the past.