I don't believe Nintendo has released the exact method of point calculation.
All I know is, like you said, the amount you gain or lose depends on how many points you have relative to the other players. Even if you come in sixth, if the two people you beat are 1000 points higher you're probably going to have a net gain. However, if you lose to people of a lower level, you're going to take a big loss.
In your case, the people who beat you were thousands of points ahead of you. It's 'expected' for people of their level to beat someone that's at your level, and so they would have gained very few points for winning and you would have lost very few points for finishing behind them. The two people you beat were likely fairly high levels, as well, which would compensate for the loss incurred by you losing to five higher-levelled opponents.
Hope this helps :)







