Trading System Tools

The Trading System Tools add-on feature of Investor/RT includes tools for defining trading systems, backtesting and optimizing trading systems using historical data, and deploying trading rules and trading systems for actual live (or simulated) trading in real-time. A trading system is composed of one or more trading rules. Each trading rule is in turn composed of a trading signal and an associated action such as buy, sell, sell short, etc. Trading signals are logical expressions (true or false statements) written in the Investor/RT Language (RTL). RTL is the language used to compose custom indicators and trading signals in Investor/RT.

Once a trading system has been defined in Investor/RT and given a name, the user can Backtest the trading system using historical data for one or more instruments. BackTesting refers to the actual execution of the trading system on a security, or set of securities over a given period of time. It simulates decision making based on past data, and is effective in refining systems in order to optimize future performance. Upon completion of the Backtest, Investor/RT displays a summary and a detailed report of the performance of the trading system over the specified period. The user can make revisions to the trading rules, add or remove rules, or adjust the trading signals used in the rules, then Backtest again to see if the revisions improved the performance of the trading system.

Investor/RT produces a detailed report showing the date and time each trade occurred, the signal that triggered the action, and account balance information at each entry and exit during BackTesting.

Creating a New Trading System

To create a trading system, use the Object Manager. Choose Trading System as the type, then click the New button. The Trading System Definition window will appear. A menu of existing trading systems, if any, appears at the top of the window. Choose a system from the menu or click the "New" button to add a new system. Investor/RT will ask for a name for the new trading system. Enter a name up to 31 characters in length.

Defining Trading Rule

The next step is to define the trading rules for the system. As mentioned before, a trading rule is composed of a trading signal and a corresponding action. The middle section of the Trading System Builder window is used for this purpose. A list of available trading signals appears at the left. Moving right, several actions are listed that can be associated with a particular signal to form a rule. To the right of the actions are window controls for specifying the quantity (applicable to buy, sell short, and certain other actions), the price at which to perform the desired action (last, open, high, low, etc.) and the periodicity (daily, weekly, 1-minute, etc.) to use when BackTesting. At present Investor/RT requires that all rules in a trading system have the same periodicity. There is also a control for picking a "chart marker" to be used when viewing a trading system in a chart. This will be discussed further below.

If not trading signals appear in the list, you must define the signals you wish to use in the trading system. Click the "New" button inside the "Define Trading Rule" area of the window to add a new trading signal. A signal setup window will appear for building the signal using RTL. For example, you may define the signal:

MACD1 < 0 AND MACD > 0

When prompted, setup the MACD as an oscillator with the desired periods. Save the signal under the name "MACD_BUY". This is a simple signal that triggers whenever the MACD oscillator crosses from below zero to above zero.

Similarly, you could add a "MACD_SELL" signal using the RTL formula:

MACD1 > 0 AND MACD < 0

When you close the signal setup window, the two new trading signals will appear in the signals list on the Trading System Builder window. Create rules by picking a signal and an action, specifying a quantity and a price if appropriate and clicking the "Add Rule" button. The newly added rule will appear in the list at the bottom of the setup window. For example, choose MACD_BUY as the signal, "BUY" as the action and enter a quantity of 500 at the "last" price. For now, set the periodicity for Daily data. After clicking "Add Rule" the new rule will read:

Daily: If MACD_BUY then BUY 500 at Last price

Similarly, add a rule to SELL when the MACD_SELL signal is triggered. Since "SELL" means sell the entire position to exit a long position there is no need to specify a quantity. For price, we can use the average price for the day (High + Low)/2. This yields a new rule:

Daily: if MACD_SELL then SELL at Hi + Lo/2 price

These two rules actually make up a complete (but simplified) trading system. There is a rule for going long and another rule for exiting the long position. Both rules depend upon the MACD indicator. We can now test the system on past data (BackTest).

BackTesting Setup

First, we must setup various BackTesting options. This is done in a separate window called the BackTest Setup window. Click the "Setup BackTest" button to access this window.

At the top of the window, specify a ticker symbol or a quote page on which to apply the Trading System. The "Maximum Position Size" settings are used when going long or short or adding to long or short positions to assure than no more than the maximum shares or contracts are purchased or shorted during any particular trade. Enter the commission and fees to apply on entry and exit of trades during the BackTest. Use the "BackTesting Period" controls to specify the time period over which to run the BackTest. Investor/RT will attempt to load data for the specified period from the database but may use less data if historical data is unavailable for a portion of the requested period. A space is provided for user comments. Comments are stored with the trading system for future reference. Click OK to return to the Trading System Definition window or click the BackTest button to run the BackTest. For convenience, there is a BackTest button on the Trading System Definition window as well.

Trading Rule Actions

So far, we have illustrated the use of BUY and SELL actions in trading rules. There are eleven actions available for forming trading rules. Each action is listed below with a description:

  • BUY - buy to open a long position, specify quantity and price type
  • SELLSTOP - sell to exit a long position, specify the selling price type
  • BUYMORE - buy to add to a long position, specify a quantity and price type
  • REVERSE - exit long position (SELL) and open a short position (SELLSHORT), specify a quantity to short and a price type.
  • SELL - sell to exit a long position, specify quantity and price type
  • SELLSHORT - sell to open a short position, specify quantity and price type
  • BUYSTOP - buy to exit (cover) a short position, specify the price type
  • SELLMORE - sell more to add to a short position, specify a quantity and price type
  • REVERSE - exit short position (COVERSHORT) and open a long position (BUY), specify a quantity to buy and a price type.
  • COVERSHORT - buy to exit (cover) a short position, specify the price type
  • CONFIRM - a special action that causes I/RT to confirm the signal by testing the next rule in sequence. The rule following a CONFIRM rule will only be tested if the CONFIRM rule is signals "true". Any number of CONFIRM rules can be stacked in succession. Once any CONFIRM rule tests "false", rule testing continues with the next "non-CONFIRM" rule in sequence.

Notice that the SELL and SELLSTOP actions do essentially the same thing, as do COVERSHORT and BUYSTOP. The actions are provided to clearly distinguish between rules for exiting a position pre-maturely (i.e. a stop loss rule) and rules for exiting normally when the trading system issues a trading signal.

Modifying Rules - Visual Markers

Each trading rule has a visual marker that can be associated with it by clicking on the marker control box in the Trading System Definition window. First, click on a rule to select it for modification. Then change the marker and click "Modify Rule" to record the change. You can also change the action, quantity, and periodicity of a rule in the same way. To view the signals for the selected rule, click the "Chart Rule" button. A chart window will appear with markers showing each bar where the rule's trading signal tested "true". Similarly, clicking the Chart System button shows a chart of the entire list of trading rules. It is important that you specify distinct markers and/or marker colors for each trading rule so they will be distinguishable in the chart window.