The formula to calculate the profit or loss of a CFD position is as follows:
Long position (Buy order):
Profit/Loss = (Closing Price - Opening Price) x Lots x Contract Size
Short position (Sell order):
Profit/Loss = (Opening Price - Closing Price) x Lots x Contract Size
Any additional costs or fees, such as commissions or swap fees, will affect your overall profit or loss.