The following basic steps should be taken in developing your trading rules. The best way to do this is to write it down as you go. You will undoubtedly change your rules, find errors, and develop rules for the many complicated situations you come across in the markets. These steps are merely the starting point.
STEP 1: What do I want the model to do?
This encompasses the markets you want to trade, the amount of money available, whether you want to capture trends or reversals, if you want to trade just one security at a time or many, if you want the model to be a fully automated robot or a hybrid decision-making tool, whether you want graphs and charts, sounds, emails, etc. or if simple Buy/Sell signals are OK, how the trades will be executed, what your time frame is (intraday, daily, weekly, monthly, yearly), and what methodology you plan to use (technical indicator rules, econometric analysis, statistical probabilities, fundamental cash flow data, intermarket analysis, etc.)
STEP 2: What are my inputs?
Will it use prices, economic data, volume, open interest, volatilities, spreads, yields, etc.? Where does the data come from? Is it real time, delayed, end of day, weekly, etc.? How do I plan to get it into my model? How will it be stored and made available to the model logic? Does it need to be cleansed? Do I need to combine it with other data? Are there user inputs or inputs from other systems, such as a P&L blotter, trading system, or risk monitoring system?
STEP 3: What are my trading rules?
This is best written out in clear and concise sentences first, then in pseudo-code, then translated to Excel formulas, VBA, or even just a trader “cheat sheet” if you plan to apply the rules manually. You need rules for entry, exit, position reversal, capital allocation (how much money per trade), capital protection (e.g. stops, position sizing), risk management, timing, etc. Once you’re in a position, what happens next if x, y and z occur? Do I enter at the close, or the next open? Do I build or exit positions one small trade at a time or do I enter or exit the entire position all at once?
STEP 4: How do I calculate my trading rules?
The first decision here is whether to use Excel formulas or VBA or a combination of the two. These can be very simple, or very complex, depending on your rules. Next, you actually need to implement and test them against real data. This is where the rubber hits the road. The rules will make or break your model so they should be based on actual real market dynamics — you need to have a real, valid reason for buying and selling, otherwise your rules will have no validity and your model will lose money. Backtesting is an extremely valuable exercise at this point.
STEP 5: How do I execute the rules?
You can execute your trades manually or set up the model to do it for you. If you plan to build a “trading robot” yet you plan to execute the trades manually, then consider that your own human behavior becomes a major component of the model performance and reliability. Such a hybrid approach makes the trading model a helpful tool only, and testing the results only indicates the potential performance assuming you (the human) are 100% reliable in executing them perfectly and on time, night or day. Fully automated trading robots work best when the trades are executed automatically through your broker’s API interface. This requires implementing an additional layer of coding or installing a pre-built order execution interface.
STEP 6: How do I track the model’s performance?
You can build functionality into your trading model to save all signals and executed trades automatically. Again, this assumes those trades are actually entered at the same price and time as the model rules say. Otherwise, you can simply enter your trades in a spreadsheet or use your broker’s performance analysis tools.
STEP 7: How do I test and improve the model?
Having a dedicated backtesting model that allows you to run it hypothetically on different data sets is highly useful. The actual trading model and the backtesting model must have the same logic. The backtesting model includes P&L logic, as well as functionality to calculate key statistics such as drawdown, volatility of returns, win-loss ratios, risk of ruin, Sharpe ratio, Treynor ratio, etc. An excellent way to test your models is to use Monte Carlo simulation on the model’s returns to create alternate distributions of returns. This uncovers the potential risk-return performance of your model across tens of thousands of market scenarios, not just the few that actually happened. Monte Carlo is outstanding at uncovering model problems that lead to unexpected losses.