If you trade stocks, you’ve probably made a few losing trades that still keep you up at night. The stock market moves quickly, and volatility can lead even the most seasoned trader to buy or sell in a panic. Whatever strategy you choose, the most important thing for your long-term returns is that you stick to it. You’d be better off if you stopped yourself before trading in a panic.

Unfortunately, human emotions are powerful, and it’s hard to think rationally when your nervous system has other plans.

Luckily for investors, advances in artificial intelligence will create a personalized trading assistant to try to make money-losing trades a thing of the past. This A.I.-powered trading assistant will analyze your trading behaviors to determine when you’re likely to make a bad trade and when it’s a good idea to swallow your anxiety, greed, or fear. It’s like a financial analyst that does the dirty work for you, allowing you to seek out new investment opportunities with peace of mind.

Imagine this: Let’s say you specialize in biotech stocks and you just found out about a new drug company whose stock is heating up fast. You want to get in before the rest of Wall Street, so you glance at the fundamentals and fill out an order to buy 1,000 shares. Before you confirm the trade, your trading assistant stops you with a popup: This trade is irregular for you. Usually, you invest in biotechs in the late stages of FDA approval. This company just started the process. Are you sure this is a good trade?

Or perhaps you invest in income stocks, and one of your holdings is down 5 percent today. You quickly decide the company is a sinking ship and fill out an order to sell your entire position. Again, your trading assistant stops your with a popup: Are you sure about this trade? You usually hold income stocks for 3-5 years. You bought this stock four months ago.

Rather than replacing the human investor entirely, the trading assistant will use A.I.’s relative strengths to complement the human brain’s weaknesses. One of A.I.’s relative strengths is its emotionless nature; when human emotions run high, it’s especially helpful to have a computer spot your trades.

In many cases, A.I. is better than a human at recognizing patterns. For example, you might have lost the most money on a bank stock, a retail stock, and a foreign oil stock. The only thing these companies had in common was a high level of distressed debt. Since the stocks are in different sectors, you might not notice this common denominator, but your trading assistant does. Next time you try to buy stocks of a company with distressed debt, you can count on getting a popup from your trading assistant. You often lose money on companies with this level of distressed debt. Are you sure about this trade?

These are just a few examples of input data to power the trading assistant. As A.I.’s underlying technology continues to advance, trading assistants will incorporate more than just trade history and company fundamentals into their algorithms. Eventually, they’ll be able to analyze your facial expressions and breathing patterns to detect panic, anxiety, or frustration.

They’ll look at your keystrokes to stop you from trading in a hurry. They’ll also become more accurate with time. The longer you use the trading assistant, the more data it collects to understand your strengths and weaknesses, allowing it to pay closer attention to the details you often glaze over.

As Apple’s Siri taught us in 2011, the “intelligent assistant” is a promising use case for artificial intelligence technology. Siri is a bit of a generalist, but as A.I.-powered bots make their way into more specific verticals, they will become experts at complementing specialized human intelligence.

Most of us, 99 percent of the time, make rational decisions. Unfortunately for investors, making irrational decisions even just 1 percent of the time is expensive and can cause huge losses in their portfolios. Investors need someone with an eye for consistency to alert them before they break the rules of their own strategy. Luckily, advanced A.I. will create just that: a trading assistant that stops you before you make a bad bet.