dtuur you were right. i was using avg(price) grouped by pair.. but some of the smaller exchanges are making this calculation wrong. so now i am using the price from the market with the highest volume for each pair (mostly btc-e)
Now it works great, thanks!
One more suggestion, I assume that many people who own altcoins buy them by depositing bitcoins on btc-e for example. And so if they want to calculate profits or losses, it may be useful if there is a field for Bitcoin as well. Even though the amount in BTC will remain the same left and right, it will the users give an easy comparison with the amount of BTC invested. I may be alone with this though.