Detecting credit card fraud is a key challenge in the financial sector, requiring advanced machine learning algorithms to improve detection accuracy while minimizing false positives. Generally, the dataset of credit cards is unbalanced because the banking sector does not provide real time dataset so the Kaggle dataset is unbalanced so we need to balance it by various techniques. This study describes a novel stacked model strategy for improving fraud detection performance. Firstly, the dataset is divided into training and testing sets, and a random forest classifier is trained using multiple class imbalance ratios, notably 1:4 and 1:10 (fraud versus non-fraud cases), to balance the dataset and improve model robustness. Furthermore, comparison visualizations examine the distribution of fraud and non-fraud instances based on RF classification scores. Results are better on 1:10 classification with 99% accuracy, recall is 93% whereas precision and f1 score is 58% and 71% respectively. And after that this model can be used to check combined common fraud and non-fraud with 1:4 and 1:10 with test data. The result shows recall is achieved with a remarkable 98% and accuracy is 99%. The results show a better balance of precision and recall, confirming the model's ability to detect fraudulent transactions. These findings demonstrate the viability of stacked models trained on different class ratios as a dependable strategy for reducing fraud in financial transactions.