Whilst setting prices based on trade values works (the stock market works this way for example) it is (or should be) self-regulating by having a very large number of traders involved in the setting of the price. So a few players cannot rig the market because they would be a small factor in trading. However, this still cannot prevent abuses caused by very large players trading or by a lot of traders all deciding to trade (eg someone with a lot of money makes a trade, that will affect the price disproportionately, similarly see tulip bubbles for examples of how prices were set irrationally by many traders)
So for a game, you need to put brakes on these, just to ensure stability in the game that would not come from the usual routes in real life.
Perhaps the easiest way is to introduce a large number of NPC players who trade on a moving (ie historical) average. Then PCs cannot manipulate the market as their trades are simply lost in the mass of other trades. Unfortunately this would also prevent the kind of price fluctuation you want. You'll have to tweak the number of NPCs to find the right balance.
The other aspect is supply and demand, you can have prices set according to the quantity of some resource. If a banana costs me $1 today, and tomorrow someone finds a new supply of bananas doubling the number present in the universe, the price of a banana will (theoretically) drop overnight to 50c. You can use the same mechanism (which won't be as extreme) to regulate prices. (obviously the opposite holds true too). If you also introduce a localisation effect, where supply is greater or lesser in various areas, you create trading routes - ie my island that makes bananas has lots of them, so price is low, whereas the city that has none, the price is high. As more of the bananas are moved from island to city, the price rises in one and drops in the other, finding a balance.
So set an arbitrary price for each resource, allow NPC movement of goods from low-price areas to high-price areas, introduce consumptions and production of these resources and let the game stabilise itself. Then the players, and random effects (eg natural disasters, increase and decrease in production, NPC attacks on trade routes, etc) will de-stabilise the prices all by themselves.
Its important to handle quantity here, rare items will hold their value regardless of where they are and won't be affected by economies unless you want to get advanced and set prices through the supply of money - that introduces inflation which will destabilise things further and require an equal continual influx of currency to keep the economy moving. This isn't such a bad thing as it means nobody can sit on their wealth and expect it to retain its value, so they have to keep working.