Take the following example :
Let's say that the current bid/ask for EUR/USD is 1.4616/19, meaning you can buy 1 euro for 1.4619 or sell 1 euro for 1.4616.
Suppose you decide that the Euro is undervalued against the US dollar. To execute this strategy, you would buy Euros (simultaneously selling dollars), and then wait for the exchange rate to rise.
So you make the trade: to buy 100,000 Euros you pay 146,190 dollars (100,000 x 1.4619). Remember, at 1% margin, your initial margin deposit would be approximately $1,461 for this trade.
As you expected, Euro strengthens to 1.4623/26. Now, to realize your profits, you sell 100,000 Euros at the current rate of 1.4623, and receive $146,230
You bought 100k Euros at 1.4619, paying $146,190. Then you sold 100k Euros at 1.4623, receiving $146,230. That's a difference of 4 pips, or in dollar terms ($146,190 - 146,230 = $40).
Total profit = US $40.