In the broad sense, stock prices are based on investors' expectations of the future value of a company -- its future earning power. But the actual selling price, at any given moment, is that at which investors are willing to buy and sell the stock. The price is not "set" by anyone. Instead, it is established by an auction process.
For instance, take hypothetical company Adam's Apples (Ticker: EVE). Let's say, for example, that the lowest price that any shareholders are willing to sell EVE for is $18. That's known as the "ask." But if no one will pay that amount, a price has not yet been established. Eventually, someone may decide to ask $17.50. When someone buys it at that price, the price will be established. Until an investor puts his or her money on the line and a transaction takes place, there is no real price or value established for that stock.
But what exactly makes the price move, seemingly at random, up and down?
Imagine that you're buying and selling oranges at a roadside stand in Orlando, Florida. You have an inventory of oranges to sell; but you're relying on making the really juicy bucks by acting as a go-between for people buying and selling oranges to each other. Because you've seeded your venture by advertising in every Disney/Universal Studios promotional guide available, everyone knows about your little stand. (Mentioning that you sell oranges in the likeness of Mickey Mouse hasn't hurt matters either.)
Therefore, everyone goes to your stand knowing you "maintain a market" in oranges.
If you want to move a lot of oranges, you most likely would buy and sell those oranges at the best price you can get at any given moment. Setting a price and sticking to it would limit your business. You would also rapidly learn that, if there are more sellers than buyers, any seller who wants to do business will have to drop his price in order to attract one of the few buyers.
(You, of course, make out just fine because you profit from the "spread," the difference between what you buy the oranges for and the selling price. The spread is your reward for "making a market," which means guaranteeing there are always oranges available for sale at a reasonable price, even if you have to pull some from your own stock to sell. Sometimes you may even buy at a higher price than you sell at; but if you're smart, you'll maintain your inventory and keep this from occurring.)
Pretty soon word spreads throughout the Magic Kingdom that the price of oranges is really low. Which is good for you, because there's not much money in offering free orange juice. Now, buyers start showing up in larger and larger numbers. Because the prices have dropped, there are now more buyers than sellers. Sellers no longer have to lower their prices to attract buyers so the opposite trend develops. Buyers are willing to pay more to induce the sellers to sell. Sellers who refused to sell at the lower price, start adding their oranges to your stock until there are enough oranges to supply the needs of all those eager buyers. Orange you glad you got into this business?
Just as you provide the go-between service at the orange stand, there are people working at the New York Stock Exchange called "specialists." Their counterparts in the over-the-counter markets (of which Nasdaq is one) are called "market makers." They don't perform their functions in exactly the same way as the orange vendor, but their roles are essentially the same -- if citrus-free -- to maintain a market for a given security and to provide a stable trading environment.
Assume you want to sell some of your shares of EVE at the current "market" price. The lowest ask price from sellers is $16.00. The market maker or specialist buys it from you at that price, hoping to sell it to someone else for at least $16.25. That $0.25 difference between the two prices is the amount the market maker pockets in return for taking the risk of buying the security without knowing with certainty what price she will realistically be able to sell it for.
Fortunately for that market maker or specialist, I offer to buy the stock at the "market price." The market maker looks around and sees that the highest price currently being "bid" by others who are specifying a purchase price is $16.25 so she sells it to me for $16.25.
But suppose there are orders on the books to buy more shares at any given price than there are orders to sell shares at that price. The market maker lines up all the orders, first by price, then by date received. The offers to buy are matched with the offers to sell. Everyone willing to pay $X (plus the spread, of course) is matched with those willing to sell for $X. Once all the stock that sellers are willing to sell for $X is gone, the price moves up, and those willing to buy for $X.25 are matched with those willing to sell for $X.25, until all those shares are sold. Market orders are filled as they come in at the prevailing price; but if a stock is moving up rapidly, the price you pay on a market order may be quite a bit higher than the price you saw quoted.
It's that ol' law of supply and demand. It works the same whether you're talking stocks, real estate, oranges, or virtually anything else being bought and sold.
Over the long-term, of course, the change in a stock's price will be determined by the accomplishments of the company rather than by these brief up and down trends that catch the eyes of short-term investors.
Sometimes, understanding the market is as easy as vitamins A, B, and C.