The world is moving towards more and more automation. Every kind of work which is done manually is being replaced by softwares (aka algo). Trading being no different. Manual executions are getting replaced by execution via algo using broker’s APIs. Manual looking of charts to generate buy/sell signal is being replaced by automated signal generation by reading the live data feed via an algo. Manual backtesting of strategy to understand past performance is being replaced by online backtesting tools to analyse the historical data. Algo is not the future, but it has become the present. Every manual aspect of trading is being replaced by algo trading. This is a major shift in the trading process. To survive this shift and continue trading profitably, we need to evolve our trading into this new domain. And the first part of evolution is learning how all of this works.
Components of algo trading
A common misconception is that algo trading is just placing orders in a broker’s system using code. There is much more to it. Ecosystem of algo trading comprises of following components:
- Formulating a trading system
- Forward testing
- Automated execution
- Trading journal
Algo trading is basically coming up with a system or a set of rules to trade. Once the rules are clear, algo trading validates the performance of these rules on the past data. If the rules are performing profitable in extreme conditions, algo trading enables the automated execution of these rules on the broker terminal. Once all of this is setup, algo trading enables logging in all the trades in a trading journal.
Let us understand each of these in detail.
Formulating a trading system
Trading system also known as a mechanical trading system is a set of rules which generates buy/sell signals to place the trades. These rules are crisply defined so that there is no scope of ambiguity in any situation. Basically a trader should know beforehand, what needs to be done in a particular situation.
Trading system comprises of rules for the following scenarios:
- Instrument to trade. E.g. : Options, Futures, Stock, Index, etc
- When to enter the trade
- How to enter the trade. E.g. go Long or Short
- Quantity to trade
- Initial stop loss
- Profit target, if any
- Trailing stop loss, if any
- Option adjustments, if any. Every minute detail of how to adjust in all market scenarios.
- Exit time for intraday trades
Each & every point mentioned above should have a clear answer, then only you have a complete mechanical trading system. If you have this, you have conquered the first step of algo trading.
Strategy is defined by rules but validated by backtesting. Backtesting is a process to verify if the strategy has given good performance in the past. This is a very good filter to weed out bad strategies without wasting any time & money on them in live markets.
Backtesting requires knowledge of coding and availability of clean historical data.
A good backtest measures the performance of a strategy on the following parameters:
- Returns after brokerage, charges & slippage
- Number of trades taken
- Number of profitable trades
- Number of loss trades
- Average profit in profitable trades
- Average loss in loss trades
- Max drawdown amount
- Max drawdown ratio
- Top 5 profits
- Top 5 losses
- Sharpe ratio
Even a good backtesting report may suffer from certain pitfalls. So ensure that the backtest is done from a reliable source as your real trading money is at stake. Common pitfalls are:
- Ignoring charges, brokerage & slippages
- Using High/Low price of the candle
- Too less data
- Unclean data
- Overfitting data / Too many filters
Once a strategy has proven its potential on the past data through extensive backtest reports, traders will get a lot more conviction on trading. If the backtest has shown 20% drawdown in the past, a 10% drawdown will not shake the trader out of the system. Backtest is super helpful for developing conviction on the trading system.
Backtest is super good to weed out bad strategies. But the strategies that have performed well on the past data may not necessarily perform good on live markets. There could be many reasons. One of the major reasons is always some of the pitfalls of the backtest which may not be obvious. To avoid this one needs to do the forward test. Forward test is also a very good way to test a strategy, if one is not able to do the backtest due to technical limitations.
In forward testing, strategy has to be deployed in live markets with minimal capital. It is good enough to test out the performance using 1 unit of stock. So the strategy will be deployed on the live market with very little capital for say 1 month or 50-100 trades. Each trade is logged in a trading journal. Once enough trades are taken, the performance of the forward test is measured against the backtest. If the performance matches, it is a big validation that the strategy is good to be deployed with larger capital.
Following parameters need to be compared between a forward test and the backtest:
- Is win rate matching
- Are avg profits of profitable trades matching
- Are avg loss on loss trades matching
- Are slippages matching with assumption in the backtest
- Is drawdown less than the backtest drawdown
Forward test is one of the most powerful ways to validate the strategy. It not only validates the strategy rules, but it also tests a trader’s emotions & psychology. If a trader is not able to execute the trades on small capital, that means that the trading psychology is not in tune with the trader’s personality. Forward testing saves a lot of capital and filters out strategies that looks good on the backtest but are actually bad.
The strategy has well defined rules, it did good on backtest, the forward test results matched the backtest performance. This is a golden state to be in. The strategy has proven its worth and ready to be deployed on live markets with large capital.
Deployment of the strategy can be both manual and automated. Automated execution has the following benefits over manual:
- Fastest possible execution of trades
- No place for emotions to break the rules
- No mental exhaustion due to continuous monitoring of screen
- Frees up a lot of time to work on something else
Since the strategy has crisply defined rules, automating it would not be tough. It requires intermediate to advanced knowledge of coding depending on the strategy. Since the real money is on line, any issue in the code may lead to loss of capital. So ensure that the service used for automation is super reliable.
There is a common misconception that once the strategy is automated, the work is done and it will keep on earning money forever. In theory, this is the case, but in reality it rarely happens. Traders have to understand that the market is an evolving organism. Market conditions keep on changing and the strategy has to be monitored to see if it has stopped performing.
Trading journal is the most powerful way to monitor the performance of strategy and traders as a whole in live markets. A beginner trader can benefit from their trading journal by identifying their mistakes. Once a mistake is identified, it can be fixed very easily.
Trading journal records the following:
- Entry date
- Exit data
- Instrument traded
- Entry price
- Exit price
Trading journal is powerful for beginners & experts alike because it points out critical mistakes in execution which may not be obvious otherwise. It helps in following ways:
- Tells if win rate is not going below a threshold
- Tells if risk per trade has not gone above 1-2%
- Tells if avg profits are much higher than avg loss to keep positive expectancy
- Tells if multiple strategies are actually non-correlated or not
- Tells if trader is overtrading
- Tells if trades are taken by breaking rule so the system
Trading is a lonely profession. Traders do not usually discuss their strategies with each other in fear of losing the edge. Trading journal is the best friend for traders, as it creates a feedback mechanism.
Algo trading is not just about executing the trades via computer. It is much more than that. It is a process to bring structure to how a trader operates. It sets up rules, verifies them extensively and then only automates them. Algo trading also sets up a feedback loop through trade records in the trading journal. Algo trading helps a beginner trader in cutting down losses & helps an advanced trader in becoming profitable. It further frees up the mind from anxiety over decision making.
If you have not already started to algo trade, do it now.
This is the fifth post of the series “Reminiscence of a retail trader”. Read the introduction post by clicking here.
Follow me on twitter and subscribe to my blog to get all the latest updates on upcoming posts of this series.