"I entered my position 3 weeks ago at a certain entry price. Now, I closed my position at a price where I should have made a profit, but instead, I realised a loss. What happened?"
The Basics of Instant PNL Realisation
When you enter a position, you have a certain Average Entry Price (avgEntryPrice) and the same Average Cost Price (avgCostPrice).
If your position is on Cross Margin and it has Unrealised Profit, the Instant PNL Realisation system will automatically realise that PNL for you. When it does this, you'll receive the Realised PNL in your wallet and your Average Entry Price gets updated to the current Mark Price. Your Average Cost Price, however, will still reflect the original Entry Price you opened your position at.
Our system will use the updated Average Entry Price to calculate your Unrealised PNL going forward. At this point, if the price moves in a direction that is adverse to your updated Average Entry Price, you will see that you have an Unrealised Loss on the position. If you close the position then, you will see a realised loss for that trade. However, you only made a loss against the updated Average Entry Price. As long as you closed in profit against your Average Cost Price, you made a profit on the trade (ignoring fees, etc).
Gauging Your Total Realised PNL
To have a comprehensive understanding of your trading performance, it's essential to track your Realised PNL over the lifetime of your position. By looking at the history of Realised PNL transactions since you opened your position, you can see the cumulative PNL realised through Instant PNL Realisation.
If you have been in a profitable position, you were realising profits over time, and any loss that you see on a particular day is just a portion of the total Realised PNL.