The relationship between oil and the stock market is a complicated one.
Generally speaking, a robust economy is good for both oil and stock prices. Expansion leads to more demand for oil. Here you see oil/stock price correlation.
Certain market sectors benefit from higher oil prices (oil producers, refiners, drilling companies, oilfield service companies, etc.). Other sectors benefit from lower oil prices (airlines, trucking companies, any industry that needs to move people or goods).
Bottom line, it's all about supply and demand. The flow of oil from the Middle East is so great, that a major producer opening or closing their valves, so to speak, make the other factors seem insignificant.
Regarding gold, it has long been considered a hedge against inflation and a flight to safety investment, both having an inverse relationship with stock prices. Gold is also used in manufacturing processes, thus can benefit from expansion, just as stock prices do.
Gold and oil prices vs stock prices? Just depends on which market factors are in play at any point in time. To me, investing in oil or gold is pretty much a pig in a poke.
TCK