How would I go about making a stock system? I understand how to do the math operations and all of that but the only thing I need help with is the random drops and stuff. I need help perfecting an algorithm that will make this stock system as realistic as possible. Here is my criteria:

Stocks will go up steady in the long run but may have ups and downs daily. Example:

http://www.eu-rise.org/wp-content/uploads/2011/07/Apple-Stock-Chart.png

Stocks will never outrageously shoot up. They have realistic peaks and realistic dips that will keep them normal.

Day range and 52wk range.

Possibly use real quotes from sites and have LUA retrieve the values.

Limit shares so that admins can release new shares if needed.

Button to add a company.

Finally, the algorithm that would contain the math needed to do all the number shit.