How trading algorithms are created

Quantitative trading isn't accessible solely to institutional traders; retail traders are getting involved as well. While programming skills are recommended if you want to produce algorithms, even those aren't always required. Programs and services are available that write the programming code for a strategy based on the inputs you provide. The code produced by the program/service is then plugged into the trading platform and trading commences. But before any of this can occur, want-to-be algorithmic traders progress through several steps deciding exactly what they want to accomplish with the algorithm, and how.

Time Frame and Constraints

While a well-programmed algorithm can run on its own, some human oversight is recommended. Therefore, choose a time frame and a trade frequency that you are able to monitor. If you have a full-time job and your algorithm is programed to make hundreds of trades a day on a one-minute chart while you are at work, that may not be ideal. You may wish to choose a slightly longer-term time frame for your trades, and less trade frequency so you can keep tabs on it.

Profitability in the testing phase of the algorithm doesn't mean it will continue to produce those returns forever. Occasionally you will need to step in and alter the trading algorithm if the results reveal it isn't functioning well anymore. This is also a time commitment that anyone who undertakes algorithmic trading must accept.

Financial constraints are also an issue. Commissions rack up very quickly with a high-frequency trading strategy, so make sure you're with the lowest-cost broker available, and that the profit potential of each trade warrants paying those commissions, potentially many times a day. Starting capital is also a consideration. Different markets and financial products require different amounts capital. If day trading stocks, you'll need at least $25,000 (more is recommended), but trading forex or futures you can potentially start with less.

Market constraints are another issue. Not every market is suited to algorithmic trading. Choose stocks, ETFs, forex pairs or futures with ample liquidity to handle the orders the algorithm will be producing. 

Develop or Fine Tune a Strategy

Once the financial and time constraints are understood, develop or fine tune a strategy that can be programed. You may have a strategy you trade manually, but is it easily coded? If your strategy is highly subjective, and not rule based, programming the strategy could be impossible. Rule-based strategies are the easiest to code—strategies with entries, stop losses and price targets based on quantifiable data or price movements.

Since rule-based strategies are easily copied and tested, there are plenty freely available if you don't have ideas of your own. Quantpedia is one such resource, providing academic papers and trading results for various quantitative trading methods. The rules outlined can be coded and then tested for profitability on past and current data. Coding an algorithm requires programming skill or access to software or someone who can code for you.

Testing a Trading Algorithm

The most important step is testing. Once a trading strategy has been coded, don't trade real capital with it until it has been tested. Testing includes letting the algorithm run on historical price data, showing how the algorithm performed over thousands of trades. If the historical testing phase is profitable, and the statistics produced are acceptable for your risk tolerance—such as maximum draw down, win ratio, risk of ruin, for example—then proceed to test the algorithm in live conditions on a demo account. Once again, this phase should produce hundreds of trades so you can access the performance.

If the algorithm is profitable on historic price data and trading a live demo account, use it trade real capital but with a watchful eye. Live conditions are different than historic or demo testing, because the algorithm's orders actually affect the market and can cause slippage. Until it is verified the algorithm works in the real market, as it did in testing, maintain a watchful eye.

Continual Maintenance

As long as the algorithm is operating within the statistical parameters established during testing, leave the algorithm alone. Algorithms have the benefit of trading without emotion, but a trader who constantly tinkers with the algorithm is nullifying that benefit. The algorithm does require attention though. Monitor performance, and if market conditions change so much that the algorithm is no longer working as it should, then adjustments may be required.

The Bottom Line

Algorithmic trading isn't a set-and-forget endeavor that makes you rich overnight. In fact, quantitative trading can be just as much work as trading manually. If you choose to create an algorithm be aware of how time, financial and market constraints may affect your strategy, and plan accordingly. Turn a current strategy into a rule-based one, which can be more easily programed, or select a quantitative method that has already been tested and researched. Then, run your own testing phase using historic and current data. If that checks out, then run the algorithm with real money under a watchful eye. Adjust if required, but otherwise let it do its job.

Compare to Similar Robo Advisors
The offers that appear in this table are from partnerships from which Investopedia receives compensation. This compensation may impact how and where listings appear. Investopedia does not include all offers available in the marketplace.