We will start with a basic trading system and then we will show how to choose the appropriate technical analysis indicators to enhance and transform your basic system into a powerful and profitable one. Basic Trading System - Open the simulator manager by clicking on "Analysis" then "Simulator". - Create a new trading system by clicking on "New" then select "Create trading system using formula editor" The trading system will be based on a single buy rule and an N-Bar stop rule Settings: Buy after three consecutive down bars Exit after 10 bars Formula: buy = istrue(close < close[1], 3); // Click on "N-Bar stop" to active the stop then update the field next to "bars" Create a huge list of technical indicator rules - Select "Analysis" then "Rules Manager" - Click on "Create" to add a new list of rules - Select this list then click on "Mass rules" (Top bar). This feature lets you create hundreds and thousands of trading rules quickly using "Masks". -------------------------------------------------------- Example: We can add two indicators (Relative Strength Index and Simple moving average) and then specify the following mask: perf(mask, a) > b "a" is an optimizable variable that varies from 5 to 10 with a step of 5 "b" is also an optimizable variable that varies from 0 to 2 with a step of 2 "mask" variable will be replaced by the technical indicators we specified in the previous step (RSI and SMA) This will result into the creation of 8 rules (2 indicators * 2 values of "a" * 2 values of "b"): perf(rsi(14), 5) > 0 perf(rsi(14), 10) > 0 perf(rsi(14), 5) > 2 perf(rsi(14), 10) > 2 perf(sma(30), 5) > 0 perf(sma(30), 10) > 0 perf(sma(30), 5) > 2 perf(sma(30), 10) > 2 -------------------------------------------------------- - Click on "Add from Time-Series Builder" - Check "Include Indicators" then click on "Next" - Click on "Select All" then on "Finish". About 170 indicators are now added to the "Time Series" panel. - In "Masks" panel, type formula "A" then click on "Create" - Replace the formula with formula "B" then click on "Create" again Formula A: perf(mask, 10) > 10 Formula B: mask > sma(mask, 30) - Click on "Create Rules" (bottom-left) to add nearly 340 technical analysis rules to your list. Find the best trading systems The idea here is to add another condition to the buy rule of the previous trading system. We want to do some quantitative analysis by backtesting each trading indicator or trading rule we have gathered previously and see whether it improves our trading system performance or not. The improvement can be measured by the annual return, drawdown, Sharpe ratio or any custom measure implemented using the "Metrics" tool. Fortunately, there is a function called "ApplyRule" that allows you to easily perform this. It takes a list of rules and an index as parameters and it returns the corresponding trading rule result. Here is the formula for our new trading system: Optimize("a", 0, 339, 1); rule1 = ApplyRule("", "All", a); buy = istrue(close < close[1], 3) and rule1; Explanation: Line 1: Create an optimizable variable "a" that varies from 0 to 339 (Total number of rules minus one) Line 2: Get the result of the rule at index "a" in a list of rules called "All" Line 3: Buy when there are three consecutive down bars and when the variable "Rule1" is true To simulate or backtest every combination, select the trading system then click on "Optimize". When the optimization is completed, select the best strategies then perform an out-of-sample testing, for each one, to measure their robustness. Note: - This example was based on two masks with no optimization. You can of course create new masks, optimize them and find strategies that are even more profitable. - It is better to start the optimization with few securities (Stocks, ETFs, Futures, Currencies ...). This has two advantages: It will speed up the optimization process and it will allow you to test how strong the results of the best performing simulations are by backtesting them later with more securities.
|