Stephen Foley: The disasters that show why we have to be on our guard with algos

US Outlook Si ves algo, di algo. If you see something, say something. It's written in all the subway cars here in New York City, a reminder we mustn't ignore suspicious packages or suspicious passengers. And as we trundled towards Wall Street station on Wednesday, I couldn't but think of it as a warning to stock-market investors, too. Si ves algo, di "algo".

Wednesday was when another computer algorithm, or algo for short, went haywire and caused chaos across the equity market.

This time the only thing that got blown up was Knight Capital. That's the name of the trading house whose faulty computer code caused a surge in orders on the New York Stock Exchange, loading the firm up with unwanted shares which it then had to dump at a loss – a $440m (£283m) loss – almost certainly ending its days as an independent player in the markets.

The rest of us had a lucky escape. This is not always the case. When the Nasdaq stock market introduced a new computer system in May to manage the opening trades of a newly floated share, it worked so badly and caused so much confusion that investors didn't know whether their orders had gone through and they pulled back from the market entirely.

You might recall that debacle: it was the flotation of Facebook. UBS alone claims to have lost Sfr349m (£229m). The broker says it put in multiple orders by accident and ended up owning large numbers of Facebook shares its clients did not need.

The list goes on. When Bats Global Markets, which operates the third-largest equity market in the US, tried to float its own shares, its computer system failed, affecting trading in every stock in the alphabet before Bats. Investors around the world saw Apple shares plunge 10 per cent in a matter of seconds. That's three high-profile disasters in little more than four months, and then there's the "flash crash" of May 2010 when, thanks to a chain of algorithmic consequences, the butterfly-wing flap of a single unusual order in the futures markets caused the hurricane of a 9 per cent fall in the Dow Jones Industrial Average within minutes.

The rise of high-speed, computerised trading has been encouraged by regulators for the past decade, since on balance it adds liquidity to markets, cuts trading costs and reduces the scope for intermediaries to gouge retail investors. But we can be under no illusions now that with complexity comes the risk of dangerous error, perhaps even of system-wide collapse.

The best we can hope for is that the situation will correct itself. The Knight's tale is a cautionary one: sloppy coding or careless testing procedures can endanger your firm. Better hire better software engineers. Regulators need to make sure they, too, hire people with the technical skills to supervise modern trading firms, and they need to consider new rules, too. Ensuring a firm has proper procedures to test new computer code is every bit as important as ensuring it has compliance procedures to prevent conflicts of interest and insider trading.

Retail investors can no more give up using the stock market than they could stop using the subway, but maybe they will now proceed more warily. As the recorded announcer said as we pulled into Wall Street, "Remain alert, and have a safe day."