as I am losing, someone must gain. Then, who is this gainer?
Not necessarily correct.
If you close a trade that you lost, that doesn't mean there's a person/broker that took the opposite trade and won.
Example:
You bought at 100 and sold at 95 so lost 5.
When you bought at 100 the person that sold you the position at 100 might have closed a winning position or losing position.
When you sold at 95 the person that bought might have just opened a long position or closed a short position at a loss or profit.
The only time YOUR trade had the opposite person/broker with the opposite win/loss as you is if the broker took your trade and didn't offset/hedge your trade.
In the forex world, brokers can offset/hedge your trade or just trade opposite you.
They will have an *A* book and *B* book for the trades/traders.
Profitable traders go in the *A* book.
Losing traders in the *B* book.
Brokers will hedge the *A* book so they don't lose $$ but will trade opposite the *B* book as those traders are *losers* so better to trade opposite to make money.
***This is just my understanding of how forex works. Not all forex brokers do this & this is NOT how it works in futures/equities but the first part is true for futures/equities.